unexpected precedence #2506

Closed
markussieber opened this Issue Aug 23, 2012 · 4 comments

Projects

None yet

4 participants

@markussieber
p=0
if X and p or= n 
  ..

is transcompiled to

if (X && p || (p = n)) {

should be

if (X && (p || (p = n))) {

in my opinion

@michaelficarra
Collaborator

Nice catch.

@satyr
Collaborator
satyr commented Sep 3, 2012

Is there a difference in behavior though?

@davidchambers

Is there a difference in behavior though?

Yes. In the first case a falsy X causes the value of n to be assigned to p. In the second case a falsy X short-circuits the expression. The expression may evaluate differently as a result, also.

@satyr satyr added a commit to satyr/coco that referenced this issue Sep 3, 2012
@satyr satyr fixed `a && b ||= c` (jashkenas/coffeescript#2506) 3737564
@michaelficarra
Collaborator

Duplicate of #2181.

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