-
Notifications
You must be signed in to change notification settings - Fork 570
Struct field assigned nil != nil #639
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
Comments
This definitely seems very messed up. Here's my attempt at doing better with dealing with it, but it's still not great. https://gopherjs.github.io/playground/#/k4XCYLcu0T I made This is why we have a proposal like #633 to clean up how these structs behave. /cc @myitcv |
Thanks. Comparing |
Thanks @theclapp Can't look in detail right now, so this is a bit of a drive-by comment. Firstly I agree @shurcooL your correction to Looking at the transpiled code: var t1 *t
_ = t1 == t1 results in: var $ptr, t1;
t1 = ptrType.nil;
$unused(t1 === t1); Whereas: var t1 *t
_ = t1.foo == t1.foo results in: var $ptr, t1;
t1 = ptrType.nil;
$unused($internalize(t1.Object.foo, ptrType$1) === $internalize(t1.Object.foo, ptrType$1)); Referring to what I think is the relevant code the case uncovered by @theclapp arises because selector expressions that result in a field value ( So immediately there is a discrepancy in the transpiled code between At which point I'd be tempted to put this in the bucket of #617. But given both Either way, we need to work out what we should be doing here (my knee-jerk reaction is that we shouldn't be Just to be clear, the comparison is irrelevant here; it boils down to the transpilation of the operands of the binary expression that matters... and this is what's going wrong |
As near as I can tell this is still a problem, even if you fix the part where I used |
Based on superficial observation only, this may be related to #843 |
Why doesn't t1.foo == nil, after I just assigned it nil? Why doesn't it even == itself?
Playground link
Am I doing something wrong? Is there a better way to deal with this?
The text was updated successfully, but these errors were encountered: