-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Readability improvements around instance_constructor #10987
Conversation
Ping @gasche (as he invited me to ping him explicitely). |
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.
Thanks for the ping! I was just reading this code this afternoon with Olivier Martinot...
I'm fine with the change, I believe it is correct, and I agree that the new names are clearer.
See various review comments.
let (args, cstr_res, _ex) = Ctype.instance_constructor cdescr in | ||
let (args, cstr_res, _ex) = | ||
Ctype.instance_constructor Keep_existentials_flexible cdescr | ||
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.
Out of curiosity, do we know what happens here? _ex
is ignored, so we cannot have existentials at this point? Or can there, and keeping existentials flexible is the right thing? (I guess we re-generalize later?)
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.
I'm not sure I understand you're question... but keeping existential variables flexible here does seem like the right thing yes.
The CI passed, so I merged. Thanks for the review @gasche ! |
Sorry for the highly controversial PR which is neither related to multicore, nor fixing any bug.
As I said earlier, I was a bit confused (I'm easily confused) when trying to review #10959. The parts which confused me are actually related to #9584.
Anyway, I'm proposing 3 commits which shouldn't change at all the observable behavior of the compiler, but which make things slightly more readable in my opinion:
instance_constructor
without being careful, it seemed like we were sometimes (whenin_pattern
isSome
) turning existentials into local types, then taking a different instance of the existentials, and returning that, ignoring the abstract types.That's of course not what happens: everything lives in the same "copy scope", so the second instance actually encounter a
Tsubst
nodes and gets the local type from before. It was a bit too subtle for me though. So I changed the code to only take one obvious instance of the existentials.(That's of course not quite true: another instance will be taken when getting a copy of
ty_args
... so I'll admit that it's debatable that this commit actually makes things more readable)in_pattern
argument toinstance_constructor
. Now it's to be typing a pattern where the existentials haven't been explicitely named, so I feel justified in changingin_pattern
for something indicating which behavior to adopt, rather than which context we were being called from a few versions of OCaml ago.Please forgive me.