-  Couldn't load subscription status. 
- Fork 471
fix error message on curried/uncurried signature mismatch #6414
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
Conversation
| hmm yeah it broke a test because it then reformats in uncurried mode: ignore(. 3)which is pretty ugly Another solution would be to give the curry mode of the function in the signature mismatch error message when it's different from the other function (or just different from the config), something like this:  | 
| What about special casing just this error message? Or is the code part controlling that a bit hairy perhaps? | 
| 
 Yeah that's what I'm trying to do:  | Value_descriptions(id, ({ val_type = { desc = Tarrow _}} as d1), ({ val_type = { desc = Tconstr (Pident {name = "function$"},_,_)}} as d2)) -> fprintf ppf "@[<hv 2>Values do not match:@ %a@ (curied);<1 -2>is not included in@ %a@ (uncurried)]" (value_description id) d1 (value_description id) d2; show_locs ppf (d1.val_loc, d2.val_loc)Weirdly, for some reason, this doesn't seem to work, am I not pattern matching curried and uncurried functions correctly? @cristianoc any idea? | 
| @tsnobip there's this helper:  | 
| 
 hmm no I haven't tried it, thanks! | 
| OK I solved it, the first value was wrapped inside a Tlink. I now generate this: are we good? | 
| Oh, right, maybe you need to recursively dig for the actual type_expr (as in: handle  Outside of that it looks fantastic! | 
| 
 Yes I could easily recursively dig for that, I pushed the current version, but if you think a recursive lookup is needed, I can add it. | 
f63152c to 70cd60b   Compare   | 
 @cristianoc can correct me but I think it's needed, otherwise triggering this will depend on the type checking itself (whether it's a substituted type, a link, and so on). | 
| There's a helper for it btw,  | 
| 
 Yes helper, no explicit recursion . | 
| ok I'll use the helper, but I have another issue that is driving me crazy, it seems like tests of super errors are run twice with different parameters and they generate two different outputs: or So the expected files are always wrong in one of the configurations. | 
70cd60b to b6efc4c   Compare   | | { desc = Tarrow _ }, | ||
| { desc = Tconstr (Pident {name = "function$"},_,_)} -> (" (curried)", " (uncurried)") | ||
| | { desc = Tconstr (Pident {name = "function$"},_,_)}, | ||
| { desc = Tarrow _ } -> (" (uncurried)", " (curried)") | 
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.
| | { desc = Tarrow _ }, | |
| { desc = Tconstr (Pident {name = "function$"},_,_)} -> (" (curried)", " (uncurried)") | |
| | { desc = Tconstr (Pident {name = "function$"},_,_)}, | |
| { desc = Tarrow _ } -> (" (uncurried)", " (curried)") | |
| | { desc = Tarrow _ }, | |
| t when Ast_uncurried_utils.typeIsUncurriedFun t -> (" (curried)", " (uncurried)") | |
| | t, | |
| { desc = Tarrow _ } when Ast_uncurried_utils.typeIsUncurriedFun t -> (" (uncurried)", " (curried)") | 
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.
hmm unfortunately it doesn't work with this helper, maybe it's too restrictive? Like working only on function value not on signatures maybe?
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.
It probably needs expand head too first, forgot about that
Edit: scratch that, already done above
| 
 @cristianoc you got any idea about this? | 
| 
 Not sure. Worth checking if running tests twice is intentional. | 
| 
 Ok I checked again, and the test is only run once but what happens is that it first complains that the old output is  This is quite confusing and frustrating, especially given that the tests pass locally. | 
This reverts commit 1f1b4b8.
| I don't figure out why yet. But, it was suspicious that the error message from the ci pointed to the wrong res and expected. Therefore I tried to rename the fixtures with the shorten name and update the expected, it seems fine. #6488 EDIT: | 
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.
Great to finally land this, good job!
| Also extremely happy about this because it | 
before this fix, error messages on curried/uncurried signature mismatch did not make sense in uncurried mode:
yielded:
Now it yields:
The not so elegant part is that it means we print curried functions with a dot in uncurried mode, which might not be very clear, but I can't think of a better solution for now.
Fixes #6413
EDIT:
It now generates instead: