-
Notifications
You must be signed in to change notification settings - Fork 233
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
Wildcard constructor patterns display an incorrect type on hover #1792
Comments
Thanks for your report @Innf107 Reproduction:
|
It's not quite the same type with parentheses though. In that case it is a single-argument constructor that takes a tuple, so e.g. type t1 = A of int * string
type t2 = B of (int * string)
let f (A x) = x (* fails because A takes two arguments but is only given one *)
let g (B x) = x (* compiles *) |
Oh you're right. Also it's not an associativity issue else the wrong result would be |
Looks like this is de-sugared by the parser into: Typedtree:
|
Yes, I'll take some time for |
Given a data constructor with multiple parameters and a constructor pattern with a wildcard like this, hovering over the
_
in VSCode shows typestring
even though it should beint * string
.Arguably,
int * string
isn't quite correct either since this is a data constructor with two arguments, not with a single tuple argument and e.g.A x
wouldn't compile, butstring
is definitely wrong.In my experience, this comes up pretty often when trying to figure out the type of a constructor's arguments when pattern matching on it. The alternative is to guess the number of arguments the constructor has and write out
A (_, _)
manually, but this is a little annoying if it has more than 3 arguments.The text was updated successfully, but these errors were encountered: