-
Notifications
You must be signed in to change notification settings - Fork 198
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
Variadic parameter error persists after type is inferred #3849
Comments
I think there are two options here, assuming we keep the current inference mechanism:
While I enjoy the ergonomics of (1), it will likely be surprising when this does not work (note mutarray): let g = (x: MutArray<num>): num => {
return x.at(0);
};
let f = (...y) => {
return g(y);
//^ Expected type to be "MutArray<num>", but got "Array<unknown>" instead
}; With the current inferencing algorithm, it can't apply a constraint that has more than one type (e.g. both Array and MutArray), so we would have to pick one. |
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Hi, This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Hi, This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
I tried this:
When I hover over
y
in my IDE, it tells me thaty
has typeArray<num>
This happened:
I expected this:
I expected the example to compile, or to get an error that I need a type annotation for
...y
Is there a workaround?
No response
Component
Compiler
Wing Version
0.25.14
Node.js Version
18.14.1
Platform(s)
MacOS
Anything else?
No response
Community Notes
The text was updated successfully, but these errors were encountered: