Skip to content

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

@advdv

Description

@advdv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions