-
Notifications
You must be signed in to change notification settings - Fork 570
Inconsistent type conversion for *js.Object #682
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
Thanks for reporting. This looks like a clear bug. |
I'll look to try and pick this up as part of #617 |
@myitcv In general, I would make the suggestion that we (all) aim to make PRs as small and self-contained as possible. That approach makes it easiest and fastest to review, merge, and revert if neccessary, spot issues, etc. On the other hand, large PRs are hard to review, slow to merge, hard to revert, etc. Of course, you should use your judgement each time. If this change is significantly easier to fix as part of a bigger change, then it's fine. I just wanted to mention this point for awareness. |
Thanks @shurcooL - completely agree with all your points. I should have been clearer in my previous comment. I dug into the bug briefly and it looked like there was more overlap with #617 than not, hence my comment to pick it up as part of that issue and PR. But having just looked further the fix is actually unrelated to #617. Pushing up a proposed fix in a separate PR shortly. |
This brings the code emitted for a type switch with a *js.Object case in line with the runtime $assertType function. In the case of a *js.Object value, we have to dereference via .$val.object. Fixes gopherjs#682
This brings the code emitted for a type switch with a *js.Object case in line with the runtime $assertType function. In the case of a *js.Object value, we have to dereference via .$val.object. Fixes gopherjs#682
This brings the code emitted for a type switch with a *js.Object case in line with the runtime $assertType function. In the case of a *js.Object value, we have to dereference via .$val.object. Fixes gopherjs#682
This brings the code emitted for a type switch with a *js.Object case in line with the runtime $assertType function. In the case of a *js.Object value, we have to dereference via .$val.object. Fixes gopherjs#682
) This brings generated JS code for a type switch with a *js.Object case in line with the runtime $assertType function. For *js.Object type, we have to dereference via .$val.object. See https://github.com/gopherjs/gopherjs/blob/4b94c02883c52ae7f268e602db1dacf7bd0fbd78/compiler/prelude/types.go#L735-L740. Fixes #682.
Uh oh!
There was an error while loading. Please reload this page.
I've discovered that doing a type switch on a *js.Object behaves differently than an explicit type assert. Playground link
Produces the following output:
where I would have expected:
The text was updated successfully, but these errors were encountered: