gopherjs icon indicating copy to clipboard operation
gopherjs copied to clipboard

Multiple assignment is evaluated in wrong order

Open LMMilewski opened this issue 7 years ago • 2 comments

Full example: https://gopherjs.github.io/playground/#/6geYC_5FAf

In the following code:

x[f()] = g()

f should be called before g but isn't. This matters in presence of side-effects.

Spec: https://golang.org/ref/spec#Assignments https://golang.org/ref/spec#Order_of_evaluation

cc @dsnet

LMMilewski avatar Jun 28 '18 21:06 LMMilewski

This is probably related, and possibly even a duplicate, of #608

flimzy avatar Jun 29 '18 07:06 flimzy

Agree that #608 may be related. Don't think it's a duplicate. As I commented there, I think GopherJS is within the spec, which is explicitly vague on the code in that issue.

For the code in this issue it's much more concrete: f() should be evaluated before g(). (When x is evaluated is not specified; it could be before f, between f & g, or after g. Which would be important if f or g modify x.)

theclapp avatar Jun 29 '18 13:06 theclapp