-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading error messages when trying to use nonexistant []=
#1490
Comments
Thanks for filing the issue, I had a quick look, I'm pretty sure there is something goofy going on in semantic analysis where the This might be a precedence issue though, which could use a bit of design discussion, there are two particularly relevant interpretations of
If we consider the first to be of higher precedence then at most the fix should do is provide a hint, that perhaps you haven't defined/imported an update: I've revised my thinking and agree with @zerbina, see their comments below, as to why the second approach should be higher precedence.
|
For more context, here's an earlier report of the same issue, albeit reported specifically in the context of To recapitulate what the compiler does at present (using
Formulated in a less implementation-centric way: |
The more I think about, the more I think that
This would eliminate a practical problem with interpreting type Container = object
# ...
proc `[]`(a: var Container, i: int): var int =
# ...
proc `[]=`(a: var Container, i: int, val: int) =
# ...
var c = Container()
c[0] = 1
Giving precedence to |
That's tricky, because the |
Example
Actual Output
Expected Output
I was super confused because my
[]
template was appearing there, but didn't realize it was missing the[]=
and not[]
.The text was updated successfully, but these errors were encountered: