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
Do not use instance ~partial for principality when typing case bodies #10364
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be other occurrences of expand_head env ty_expected
in Typecore
than the ones you chose to "protect" in this PR.
Can you explain how/why some are protected and not the others?
typing/typecore.ml
Outdated
(p0, p, {type_kind=Type_variant cstrs}) -> (p0, p, cstrs) | ||
| (p0, p, {type_kind=Type_open}) -> (p0, p, []) | ||
| _ -> raise Not_found | ||
|
||
let extract_label_names env ty = | ||
try | ||
let (_, _,fields) = extract_concrete_record env ty in | ||
let (_, _,fields) = | ||
extract_concrete_record env (protect_extraction env ty) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call to protect_extraction
is redundant with the one done inside extract_concrete_record
.
And actually, I think the calls inside extract_concrete_variant
and extract_concrete_record
should probably be pushed inside extract_concrete_typedecl
(which has no other caller).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted.
I would prefer not to move that to Ctype
, as this is really Typecore
related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, would it make sense to have a final definition of extract_concrete_typedecl
in Typecore
and rename the version in Ctype
to unprotected_extract_concrete_typedecl
?
46b28d3
to
599e3e7
Compare
I wish that wasn't done in this PR. |
Do you mean that I should first do a PR for the revert, then one for this. |
Put differently, I would prefer we discuss both changes jointly. |
Good question. The one I added are just those that caused errors in the test suite. I have made a pass over |
A few more remarks.
|
I have rebased. |
Side note: The reversal of #9811 is necessary to fix the issue described in #10383 (comment) |
Only about reverting #9811 here; I'd have liked to discuss that further. |
I'd like to add some precision after a chat with @trefis, regarding the revert of #9811, the issue in parsexp mentioned above can be split into 2 separate issues:
This can be fixed with some annotations on the let bindings above the matches: janestreet/parsexp@4a4f08e
This one was classified too fast as an error by myself due to the status of warnings in dune. For this one, the fix is a litte different and requires the user to annotate the expression inside the first case of the match: kit-ty-kate/parsexp@2ea32ee Given it is the only opam package that has this issue we might want to discuss it further to understand if these two new behaviours are expected or not. Regardless I've pined the JaneStreet maintainer to make a release of parsexp with the first patch as it is already merged. |
It looks like both the failure and the warning have the same cause: some annotation being lost. So I'm not sure that split is so relevant. |
Sorry for the slow answer, I was giving an intensive course in Kyushu. For the rationale of combining this with reversal of #9811, the best answer is to look at the changes in warnings/errors. Another option would be to work harder at turning the errors in principal mode into warnings, but I'm not sure it is worth the extra complexity (and this can be done independently). |
Sure, because trying to get a warning implied adding some non trivial code, backtracking, etc. Which I believed is the source for many of the issues we've seen. Apparently I'm the only one who cares. I'll let someone who doesn't care (or who disagrees with my assessment!) approve this PR. |
OK, I'm going to split this one in two, so that you can approve the change here, and somebody else can approve the reversal. |
Let's perhaps ping @lpw25, @gasche and @Octachron here first, I'm believe they can follow what's going on. (And are likely to have an opinion). Sorry for all the trouble @garrigue! |
Ok, then let me state my point of view. Now, what to do with the non-principal mode. This said, if we just remove the special case for In the end, my impression is that we agree that this PR is the way to go, the only difference being whether to remove the two lines that allow inter-branch propagation in non-principal mode or not. |
I tend to agree with @garrigue here: decreasing the gap with the But thinking about the issue, I am probably the one in the wrong here: I should have opened a reverting PR in trunk to mirror the revert in the 4.12 branch. Should I do that right now? |
@Octachron I you want to do that, you can just cherry-pick the first commit from this PR. It already solves the conflicts, and would avoid new conflicts in this PR. |
@trefis You are talking about parts that are not covered by this PR? |
The first |
7b9e529
to
8470200
Compare
I did the fix, and now understand your comment: this recovers the symmetry in |
For me, it's ready. I'm just waiting for a final review. |
8470200
to
f2b7ee8
Compare
@trefis rebased. |
f2b7ee8
to
4b438c4
Compare
Hm, I just approved because I looked at the changes in The makefile changes feel out of place in this PR. And I would enjoy a one-sentence explanation of why the bootstrap is needed before anyone merges. |
I'm working on an M1 Mac, and this makefile change avoids having to reboot every 30mn. |
Ok, I checked.
Namely, the file More precisely, |
4b438c4
to
cf3d9e9
Compare
See PR #11288 which systematically adds |
I asked @trefis directly and he agrees that it is ok to cherry-pick the fix to 5.0 . |
Do not use instance ~partial for principality when typing case bodies (cherry picked from commit 357b42a)
Cherry-picked on 5.0 as ba12c0e (with the test fix and the correct bootstrapping) |
Do not use instance ~partial for principality when typing case bodies
This is a follow-up to #10362.
For some reason,
Typecore.type_cases
was usinginstance ~partial
when typing bodies of branches in principal mode.It appears that is was due to spurious scope updates on the expected type when using it to find concrete type definitions.
This PR does several things:
-principal
anyway.ty_res
for all case bodies in principal mode.generic_instance
where needed.