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

Fails on pure functions that are spuriously bound #105

Closed
webbedspace opened this issue Mar 1, 2016 · 5 comments · Fixed by benjamn/recast#349
Closed

Fails on pure functions that are spuriously bound #105

webbedspace opened this issue Mar 1, 2016 · 5 comments · Fixed by benjamn/recast#349
Labels

Comments

@webbedspace
Copy link

Consider this code:
var x = function() { return 2; }.bind(this);
This incorrectly becomes const x = () => 2.bind(this);.

@nene
Copy link
Collaborator

nene commented Mar 1, 2016

Thanks for reporting. That's quite an important bug.

@nene nene added the bug label Mar 1, 2016
@nene
Copy link
Collaborator

nene commented Mar 3, 2016

Turns out to be a bug in recast: benjamn/recast#264

Hopefully Recast can fix it soon enough, so we don't have to create a workaround.

nene added a commit that referenced this issue Mar 3, 2016
nene added a commit that referenced this issue Mar 6, 2016
Resolves the issue of Recast bogusly printing the short form
of arrow function when it's bound with .bind(this)

Refs #105
@nene
Copy link
Collaborator

nene commented Mar 6, 2016

This is now mostly solved by simply removing .bind(this) from arrow functions. So the above code becomes:

const x = () => 2;

The issue still remains when one decides to call some other methods, like:

x = function(a,b){ return a+b: }.apply(this, [1, 2]);

This should be a fairly rare scenario, so waiting for Recast to fix their bug.

@mdebbar
Copy link
Contributor

mdebbar commented Dec 10, 2016

Hey @nene, you've got a nice project here! And my first contribution would be to fix this long standing bug in Recast :)

@nene
Copy link
Collaborator

nene commented Dec 11, 2016

Thanks!

@nene nene closed this as completed in #197 Jan 21, 2017
nene added a commit that referenced this issue Jan 21, 2017
nene added a commit that referenced this issue Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants