You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ zig test x.zig
./x.zig:4:5: error: method cannot be called because of field with same name
fn y(x: @This()) void {
^~~~~~~~~~~~~~~~~~~~~~~
Actual Behavior
$ zig test x.zig
x.zig:12:10: error: type 'void' not a function
_ = x.y();
~^~
So this is a bit awkward. I don't know if maybe status quo is actually fine here but I don't think it is because this is ambiguous: if I do x.y() here, am I trying to call the struct's field y because I think it is *const fn(...) X or do I want to call the method fn y(x: @This()) void? I think it should simply be an error to define this method like that because it does seem to be impossible to actually call the method I defined.
Also, this error is also simply confusing when in your head you intended to call the method but the error talks about some field that you don't have in your head, so I think that's another reason to do a change here.
Also I have the suspicion this might be a duplicate so I apologize for that in advance.
The text was updated successfully, but these errors were encountered:
wooster0
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Sep 29, 2022
Zig Version
0.10.0-dev.4176+6d7b0690a
Steps to Reproduce
Expected Behavior
Actual Behavior
So this is a bit awkward. I don't know if maybe status quo is actually fine here but I don't think it is because this is ambiguous: if I do
x.y()
here, am I trying to call the struct's fieldy
because I think it is*const fn(...) X
or do I want to call the methodfn y(x: @This()) void
? I think it should simply be an error to define this method like that because it does seem to be impossible to actually call the method I defined.Also, this error is also simply confusing when in your head you intended to call the method but the error talks about some field that you don't have in your head, so I think that's another reason to do a change here.
Also I have the suspicion this might be a duplicate so I apologize for that in advance.
The text was updated successfully, but these errors were encountered: