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

Unsaturated uncurrying #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Unsaturated uncurrying #22

wants to merge 4 commits into from

Conversation

FrigoEU
Copy link
Contributor

@FrigoEU FrigoEU commented Jan 1, 2018

Hey,

This should fix #20 .

I also added two unit tests for uncurry.js, one to test the basic functionality and one to test my special case mentioned in the issue. just run it with node unittest/uncurry.js.

@FrigoEU
Copy link
Contributor Author

FrigoEU commented Jan 2, 2018

Oh dang, I've been screwing around with my branches and accidentally pushed my fix for #21 onto this branch as well. If you want I can make this into a seperate PR. They're all seperate commits though, so you can still see the changes seperately like this.

The problem in #21 was that when you make the uncurried function, you take the body from the original curried function and put that into the uncurried one. When we're in this recursive situation that I described in the issue, so first uncurrying the outside function and then the inside, when you reach the inside function, the binding that babel gives you actually refers to the original curried function, since that's where you got the body from (via x.body).

Doing a deepClone stolen from babel-types, which removes all loc and private information which is I suppose what babel uses to find these bindings, you make a brand new AST. When you're then descending into the inner function and uncurrying that, there will be no more link/binding to the original curried function.

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

Successfully merging this pull request may close these issues.

Problem with unsaturated uncurrying
1 participant