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

Remove subsumed fix for #4862 #12932

Merged
merged 4 commits into from Jan 26, 2024
Merged

Conversation

garrigue
Copy link
Contributor

@garrigue garrigue commented Jan 24, 2024

#4862 was fixed in 3.12 by using backtracking in Typecore.type_label_exp.
However, it seems that this has been useless for a long time now (checked that the example compiles fine in 4.07 without backtracking).
So let us remove this useless backtracking.
Also, properly call enforce_current_level when there are no variables, and remove a superfluous generalize_structure in type_exp/Pexp_let.

@gasche
Copy link
Member

gasche commented Jan 24, 2024

It's ironic that we spent a fair amount of effort discussing this backtracking code, which turns out to be unnecessary after all :-)

Two questions:

  • Is the testcase of small bug in relaxed value restriction #4862 part of the testsuite?
  • The problem with small bug in relaxed value restriction #4862 came from an expected_type annotation introducing a contravariant occurrence, which would then block generalization. Can you explain how the current implementation avoids this issue? (Is it still avoided if the user writes an explicit annotation, { f = (lazy (raise Not_found) : ('a list -> int) Lazy.t) }?)

@garrigue
Copy link
Contributor Author

  • The test is in typing-poly/poly.ml.
  • { f = (lazy (raise Not_found) : ('a list -> int) Lazy.t) } has never been accepted, as named variables are not generalizable locally.
  • maybe you meant { f = (lazy (raise Not_found) : (_ list -> int) Lazy.t) }, which still works after removal.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

I'm still not sure why the example works when it did not work before, but I can tell that the code is vastly simpler so I'm all for it if it still passes the testsuite. Approved.

@garrigue
Copy link
Contributor Author

Since the original fix was introduced in 3.12, before the addition of GADTs, a lot has changed since then. It is not too surprising that this kind of bug was actually fixed by other changes.

@garrigue garrigue merged commit 0c278a9 into ocaml:trunk Jan 26, 2024
11 checks passed
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.

None yet

2 participants