-
Notifications
You must be signed in to change notification settings - Fork 471
[Super errors] better arity mismatch error for uncurried function #4940
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
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),a,_),_,_)}) :: | ||
(_, {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),b,_),_,_)}) :: _ | ||
) when a <> b -> | ||
let extractArity s = |
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.
Is this too weird? Should I just pattern match all the way from arity0
to arity22
?
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.
pattern match all the way from arity0 to arity22
that would be an explosion of pattern match
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.
why it is still sound ? since we own the Js.Fn module which only contains type definitions for arity*
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.
- can you extract this into a toplevel function parameterized by
a
andb
so that it can be reused later (for other syntaxes as well)? - this looks like the same pattern match in loc 185-188, so you should merge it there
- I also think that
a <> b
seems to be not necessary since whena = b
, there should be no such error message
This function expected 2 arguments, but got 3 |
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 rephrase of such error message looks great
458fb64
to
9b92bb7
Compare
Fixes rescript-lang#4939 The previous message was also wrong (?). The types were flipped; if the function expected 1 and got 2, it'd say "this function has arity2 but was expected arity1".
(* assumption: the module Js.Fn only contains types from arity0 to arity22 *) | ||
String.sub s 5 ((String.length s) - 5) | ||
else | ||
raise (Invalid_argument "Unrecognized arity type name.") |
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.
nitpicks: this should be assert false
Fixes #4939
The previous message was also wrong (?). The types were flipped; if the
function expected 1 and got 2, it'd say "this function has arity2 but
was expected arity1".