-
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
#9148 extension constructor printing discrepancy in REPL #9440
Conversation
Context for other people: the issue that details the problem is #9418. |
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.
The code looks sensible, thanks, but I would be reassured to see regression tests in the testsuite for this fix. Tests could be written as expect-style tests in a new file testsuite/tests/tool-toplevel/printval.ml
-- see tests/tool-toplevel/use_command.ml
for an example of expect-style test to reuse.
It would be nice to have first the case that is working well (non-extensible constructor), then the extensible version, and possibly an example with an extensible GADT (if you know how to write those) where there is a difference between the constructor's result type and the type declaration parameters.
toplevel/genprintval.ml
Outdated
List.map | ||
(function ty -> | ||
try Ctype.apply env type_params ty ty_list with | ||
Ctype.Cannot_apply -> abstract_type) |
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.
Could this logic, which is used in several different places in the module now, be moved to its own auxiliary function?
Changes
Outdated
@@ -330,6 +330,9 @@ Working version | |||
on Power and Z System | |||
(Xavier Leroy, review by Nicolás Ojeda Bär) | |||
|
|||
- #9440: for a type extension constructor with parameterised arguments, | |||
REPL displayed <poly> for each as opposed to the concrete values used. | |||
|
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.
Could you include a credit line with your preferred name (we have a preference for full names if you are fine with it), and potentially reviewer names?
Ah, the marvel of testing! I hit a snag with the GADT: the constructor description of the extension has its cstr_res param set to 'int' rather than a tyvar that corresponds to that in cstr_args, so I don't see how a cstr_arg can get instantiated from a ty_list member (via Ctype.apply). |
I am not sure from your message whether there is a problem with the new implementation or not. In your example with the extensible GADT, getting Other tests you could use are type 'a t += Char : char -> int t;;
Char 'a';;
type 'a t += P : 'a * bool -> 'a t;;
P (2, true);;
type 'a t += Q : 'a -> ('a * bool) t;;
Q 2;; those should be printed without The reason why |
thanks for that explanation. then there is no problem after all.
entailed an existential type in 'b so are:
equivalent? |
Yes, in GADT constructors the type-declaration parameters are not in scope. This is why it is customary to use |
Actually, could you use Otherwise the code looks very nice to me now, this is good to merge if/when the CI agrees. Thanks! |
0c55827
to
05dc4ca
Compare
ping @gasche |
Ah, apologies for dropping the ball on this issue. I need to rebase the PR, but hopefully it is still good to merge. |
05dc4ca
to
49e31e1
Compare
fixes ocaml#9148 genprintval.tree_of_extension was missing instantiation of constructor argument types. the Ctype.apply code is factorized out from a number of other places.
49e31e1
to
8f87147
Compare
for a type extension constructor with parameterised arguments,
REPL displayed
<poly>
for each as opposed to the concrete values used.patch copies over code used for variant constructors.