Skip to content

f() in [] #1099

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
satyr opened this issue Jan 31, 2011 · 9 comments
Closed

f() in [] #1099

satyr opened this issue Jan 31, 2011 · 9 comments
Labels

Comments

@satyr
Copy link
Collaborator

satyr commented Jan 31, 2011

$ coffee -bpe 'f() in []'
var _ref;
;

$ coffee -bpe 'f() in [x]'
var _ref;
(_ref = f()) === x;
@michaelficarra
Copy link
Collaborator

The second one is just an optimization issue, right? An unnecessary _ref.

@thejh
Copy link
Contributor

thejh commented Mar 27, 2011

Pull request #1242 contains a fix.

@thejh
Copy link
Contributor

thejh commented Mar 28, 2011

closed by 0497c07: instead of nothing, compile to false

"if a in []"

jashkenas pushed a commit that referenced this issue Apr 9, 2011
michaelficarra added a commit that referenced this issue Apr 9, 2011
willmoffat pushed a commit to willmoffat/coffee-script that referenced this issue Apr 21, 2011
@satyr
Copy link
Collaborator Author

satyr commented Oct 3, 2011

$ coffee -bpe 'f() in []'
var _ref;

false;

$ coffee -bpe 'f() not in []'
var _ref;

false;
  • f() should still be evaluated.
  • not in result is incorrect.

@satyr satyr reopened this Oct 3, 2011
michaelficarra added a commit that referenced this issue Oct 3, 2011
`not in []` unconditionally compiled to `false`
@xixixao
Copy link
Contributor

xixixao commented Jan 22, 2014

Any reason for this optimization? I'll make a PR to remove otherwise. Seems nonsensical.

@vendethiel
Copy link
Collaborator

Whatever's the reason for this optimisation (avoid a call to the helper seems obvious), it clearly introduces bug (coco removed this optimisation totally).
I tried to take a stab at fixing this, but the tests are failing in several (weird, ofc) ways for me, and git bisect gives me segfault in rm and other thing. Well, windows...

@xixixao
Copy link
Contributor

xixixao commented Jan 22, 2014

Let's just remove it, why would you ever want to write x in []? The only optimization that would make sense would be to check for length in the helper and I assume that wouldn't speed it up much. +1 to remove it.

@jashkenas
Copy link
Owner

. +1 to remove it.

Go for it. That is quite silly indeed.

@michaelficarra
Copy link
Collaborator

Don't remove the optimisation for a in [b] -> a === b, a in [b, c] -> a === b || a === c, etc, though.

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

6 participants