-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dynamicIsBottom not handled correctly by strong mode generic inference #29041
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
Comments
CC @leafpetersen ... hit this working on https://codereview.chromium.org/2456803004/ but the problem already exists in current code. |
I don't think this has anything to do with inference per se, unless I'm missing something. This came up in a language meeting a while back - @floitschG or someone pointed it out. Basically, we have a soundness bug at the interaction of dynamic as bottom and covariant generics. If you have something like: /// No analysis errors in this code
class A<T> {
void oops(void f(T a), T x) {f(x);}
}
void main() {
void takesInt(int x) { x.abs();}
A a = new A<dynamic>();
a.oops(takesInt, "hello");
} there is no implied covariance check on the first parameter to This has been on my TODO list for a while. I really just want to look into getting rid of fuzzy arrows, but to do that I need to evaluate the impact on internal code and fix anything that needs to be fixed there. I believe that there is a fallback position (or perhaps a first step?) that is based on only treating function types which syntactically mention |
The reason I mention inference, is given an argument type A: |
Maybe? Is it clear that inferring That seems reasonable - we could certainly make inference recognize |
I think we can close this. It sounds like we're going to look at removing fuzzy arrows: #29299 |
In particular, this affects cases like:
Note the two cases are different: in the first one, we have a definite function, vs the second one we don't. If we infer
o.fold<dynamic>
... I don't thinkfold
will end up doing the correct checks on invoking the callback (it would need to be a dcall), so this leads to a soundness problem at runtime.I can't fix the soundness problem however, without breaking inference the
var a = o.fold ...
line, because we'd need to know the lambda is definite and thus inferring<dynamic>
is sound fora
but not forb
The text was updated successfully, but these errors were encountered: