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

allow locally abstract type and type constraint on component definitions #151

Merged

Conversation

glennsl
Copy link
Contributor

@glennsl glennsl commented Feb 25, 2022

This makes the ppx not reject locally abstract type definitions (e.g. (type a)) and type constraints on component definitions.

For example, these used to be rejected:

let%component make (type a) ~(foo : a) : _ = div [||] []
let%component make : type a. foo:a -> _ = fun ~foo:_ -> div [||] []

with the error

react.component calls can only be on function definitions or component wrappers (forward_ref, memo).

The latter also produced the error:

Fatal error: exception (Invalid_argument "react.component calls cannot be destructured.")

Which has been improved, along with a few other errors, by using Location.raise_errorf instead of invalid_arg.

Copy link
Member

@davesnx davesnx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@glennsl glennsl force-pushed the fix/ppx/locally-abstract-type-component branch from c9c3864 to f7a708d Compare March 15, 2022 19:52
Copy link
Collaborator

@jchavarri jchavarri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 🚀

@jchavarri jchavarri merged commit ebe8da7 into ml-in-barcelona:main Mar 15, 2022
@glennsl glennsl deleted the fix/ppx/locally-abstract-type-component branch March 15, 2022 20:04
@tjltjl
Copy link

tjltjl commented Mar 16, 2022

Really great! I just bumped into this yesterday :D

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.

4 participants