ppxs: no empty polymorphic type binders in parsetree#11148
ppxs: no empty polymorphic type binders in parsetree#11148Octachron merged 1 commit intoocaml:trunkfrom
Conversation
|
The fact that our own parsetree uses this empty-polymorhpism gives me cold feet. We are telling PPX authors to that it is invalid, with a special case for when our own parsetree producer actually uses it. Is there a reasonable way to avoid using this horrible hack in the parsetree, to avoid the hypocrisy? |
|
For example, maybe we could:
|
|
Well, I suppose that the special processing for non-quantified types could be done in |
|
I had a look at moving the processing of constraints on let binding to typecore. That seems potentially simpler, I will submit a PR once my todo list for 5.0 is less full. |
|
ping @Octachron |
ff485f1 to
4b60af6
Compare
|
I have updated this PR now that the parsetree is not using empty binders in encoding anymore. |
4b60af6 to
b29306c
Compare
|
small side-question about these kinds of parsetree invariants: What about introducing a non-empty list type to prevent something like this by construction? maybe that's more useful for records/tuples -- but preventing invalid data by proper type construction seems like a good property. |
|
It would make sense, but it is a more involved change: |
gasche
left a comment
There was a problem hiding this comment.
Sorry for forgetting about this PR. I am fine with the new, simpler version. This might break some ppx-produced code, but that code would probably have broken in more obscure ways later on in the type-checker, so this is in fact an interface improvement.
b29306c to
b901b03
Compare
This PR proposes to check that ppxs do not produce parsetree with empty explicit universal quantifications, for instance in fantasy syntax
instead of
Adding this invariant avoids the need to handle unexpected and sometimes invisible (see #11129)
Ptyp_poly([],_)in the typechecker itself.There is however a small exception to this rule for constraint on patterns, due to the fact that
is currently encoded as
and the ast pretty printer relies on this encoding to resugar the second form in the first form.
close #11129