Do not understand the error when trying to add to seq inside loop

2024-02-26 Thread didlybom
This particular error (a signature that completely matches except for the `var` part) has tripped me way too many times, so this is a great improvement! It'd be even better if the compiler could somehow also realise that the problem is due to the implicit `items` being used and gave you the advi

Do not understand the error when trying to add to seq inside loop

2024-02-25 Thread thecryptogeek
Wow, you people move fast. These small things make an actual difference for newcomers. Thank you.

Do not understand the error when trying to add to seq inside loop

2024-02-25 Thread ringabout
progress:

Do not understand the error when trying to add to seq inside loop

2024-02-23 Thread Araq
I get what you say and the compiler error messages are constantly improving but Nim's design goal never was "learn the language by bumping into its error messages". There are plenty of tutorials that teach you the basics.

Do not understand the error when trying to add to seq inside loop

2024-02-22 Thread thecryptogeek
That's really sad to hear and I hope a way can be found to improve these compiler errors. I say this because the 5 people I have turned on to Nim all loved it at first, but all left it because they didn't understand the compiler errors and therefore ended up getting stuck. 1 went to Rust, 1 to

Do not understand the error when trying to add to seq inside loop

2024-02-21 Thread termer
You could check for a signature that matches everything except the var part, then offer the advice "add(var seq[T], sink T) would match, but argument 1 is not mutable." This would at least give a clue, and doesn't require the compiler to have any additional context.

Do not understand the error when trying to add to seq inside loop

2024-02-21 Thread Araq
> I think the compiler could give an error like: Trying to modify immutable > object (row.add(42)) It used to do that but it's somewhat hard to get this better error message back. :P

Do not understand the error when trying to add to seq inside loop

2024-02-20 Thread xigoi
But the compiler can’t really know that because `add` could be anything.

Do not understand the error when trying to add to seq inside loop

2024-02-20 Thread thecryptogeek
A. Thanks. That's all I needed to know. I will say, that in this case (as in others I've come across) I think the compiler could give an error like: Trying to modify immutable object (row.add(42)) That would have explained it to me in 1 second.

Do not understand the error when trying to add to seq inside loop

2024-02-20 Thread thecryptogeek
I do not understand why this throws an error. What's the difference? What am I not understanding here? var s = newSeq[seq[int]](3) for row in s: row.add(42) Run Error: type mismatch Expression: add(row, 42) [1] row: seq[int]

Do not understand the error when trying to add to seq inside loop

2024-02-20 Thread demotomohiro
You get compile error because `item` iterator doesn't have var return type: When you modify elements of a seq, you need to use `mitem` iterator: var s =