Skip to content

non-pointer receiver gets modified by method execution through interface #783

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

Closed
advdv opened this issue Mar 31, 2018 · 4 comments
Closed

Comments

@advdv
Copy link

advdv commented Mar 31, 2018

Hey everyone!

First and foremost: thank you for this awesome piece of software! I've encountered a bug in which gopherjs handles interface calls on non-pointer receiver structs. It seems (to me) quiet severe but I couldn't find any bug that reported this. I'm on Go 1.10 and GopherJS 1.10-2.

When running this playground: https://play.golang.org/p/sIjx8DQWMpO. We see that struct fields modified in methods that do not have a pointer receiver indeed have no effect:

$ go run main.go 
0 0
{0} 0

Running the same code using gopherjs https://gopherjs.github.io/playground/#/0pktxkdKEX will yield a different result: the modification to the non-pointer receiver is effective outside the call:

$ gopherjs run main.go 
gopherjs: Source maps disabled. Install source-map-support module for nice stack traces. See https://github.com/gopherjs/gopherjs#gopherjs-run-gopherjs-test.
0 0
{1} 1
@myitcv
Copy link
Member

myitcv commented Apr 1, 2018

@advanderveer I think this is a dupe of #661?

A long time ago I pushed up #669 in order to address this; apologies, dropped the ball on getting it merged. I'll see that through now, but in the meantime perhaps you could verify whether it's the same issue and confirm that my PR addresses things from your perspective?

Thanks

@advdv
Copy link
Author

advdv commented Apr 2, 2018

Thank you! #669 indeed fixes the issue i'm having

@myitcv
Copy link
Member

myitcv commented Apr 2, 2018

@advanderveer no problem. Can I suggest you close this issue and subscribe to #661 and #669 for updates?

@advdv
Copy link
Author

advdv commented Apr 3, 2018

sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants