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

fix(compiler): disable automatic uncurrying #90

Closed

Conversation

nicobao
Copy link
Contributor

@nicobao nicobao commented Mar 28, 2021

Closes #44
I am not sure exactly what is expected. This is what I am working on at the moment.

@michallepicki
Copy link
Contributor

michallepicki commented Mar 30, 2021

I think (I may be wrong) because function body code generation and typespec generation are currently separate, the next thing that will be needed here, is returning an anonymous function in function application translation when there are less arguments provided than the function expects. To see how many arguments a function expects I think we already have arity in that clause in the Erlang AST here so we don't need to call Uncurry.uncurry_tarrow, but read the arity from there and compare with the length of args

@michallepicki
Copy link
Contributor

michallepicki commented Mar 30, 2021

So I think what I'm proposing is to keep the uncurrying, but do a little bit of work detecting when additional anonymous function wrapper is needed instead. What do you think about it @nicobao @Ostera ? Do you think it could work?

@nicobao
Copy link
Contributor Author

nicobao commented Mar 30, 2021 via email

@michallepicki
Copy link
Contributor

michallepicki commented Mar 30, 2021

I looked into this angle, it might work because the information we would need is in the typedtree, but with the current data structures we lose the arity information for function references that are just local identifiers here, so we don't have it available here. It would be nice to carry over additional type information (in this situation, the arity) for those identifiers. I am not sure if this is something that would live in the Erlang AST or it would be an additional accumulator in mk_expression

@michallepicki
Copy link
Contributor

michallepicki commented Mar 30, 2021

And in addition to that we would need to know when other expressions are actually functions as well, and know their arity, e.g. we would know how many arguments a partially applied Expr_apply needs as well when resolving the next application... It would be messy and almost begs for an intermediate format between the typedtree and the erlang AST (typederltree? :D) but I think it's possible

@michallepicki
Copy link
Contributor

@nicobao I think I got it working in #92 , just need to fix specs :)

@leostera
Copy link
Owner

leostera commented Jan 8, 2022

Hi! 👋🏽 since I'm currently not working on and have no plans to continue working on this version of the compiler, I'll close this PR. Thanks a lot for your contribution 🙏🏽

@leostera leostera closed this Jan 8, 2022
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.

Partial function application compiles to wrong erlang
3 participants