-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
frontend type inference emits "UnknownType" instead of DynamicType #32847
Comments
Yes, I'll take a look. |
In the That expectation is Proposed fix: https://dart-review.googlesource.com/c/sdk/+/52521 |
Oy, Dart "least" upper bound. Here's a sketch of what I think should be happening: There are two pieces of "state" associated with block body function inference:
For each return statement
For each return statement
The final inferred return type of the function is:
So for this specific example, Visiting Visiting
The greatest closure of You can think of this as inserting an implicit cast to the greatest closure of the downwards context on each return expression, except that of course the cast is unnecessary by construction. |
It's interesting that you say that the greatest closure is And there's this code here that implements It was changed deliberately in https://codereview.chromium.org/2872763002/ and the comments were left stale. (Edited to add: that comment is confusing to me anyway because it seems to have swapped covariant and contravariant, or am I thinking of it wrong?) |
Consider this example:
It appears that type inference correctly infers that the first closure return an
Iterable<dynamic>
, but it doesn't infer the same thing for the second closure. Instead it generatesIterable<UnknownType>
. This causes failures down the line (we noticed the failure also as a crash in the dart2js backend).Here is the output from dumping the IR with fasta-compile:
@kmillikin - can someone on the FE side take a look?
The text was updated successfully, but these errors were encountered: