Skip to content
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

unexpected precedence #2506

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

unexpected precedence #2506

markussieber opened this issue Aug 23, 2012 · 4 comments
Labels

Comments

@markussieber
Copy link

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
Copy link
Collaborator

Nice catch.

@satyr
Copy link
Collaborator

satyr commented Sep 3, 2012

Is there a difference in behavior though?

@davidchambers
Copy link
Contributor

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 added a commit to satyr/coco that referenced this issue Sep 3, 2012
@michaelficarra
Copy link
Collaborator

Duplicate of #2181.

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

No branches or pull requests

4 participants