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
dart2js type warning following is check #10776
Comments
This comment was originally written by ngeoffray@google.com Pete, which part of the Dart language specification says that it is required to emit a warning? Added NeedsInfo label. |
To be clear I believe that this should not be a warning. I'm not sure how type inference relates the 'static types' referenced by the language spec. |
This comment was originally written by ngeoffray@google.com I wrote too fast, I meant "which part of the Dart language specification says that we should not emit a warning?" Thing is, I don't think this is specified, so to avoid warnings, one needs to change type annotations. cc @peter-ahe-google. |
So this is what the code should be? if (f is Bar) { The original syntax seems like a straightforward assumption, it's something even the Closure JS compiler can do. So is this a language issue then? cc @rakudrama. |
This comment was originally written by ngeoffray@google.com After talking to Johnni, yes this is a language issue. Until this is fixed, we need to do write what you wrote, or just not put a type annotation at the declaration of 'f'. cc @gbracha. |
The analyzer is completely non-compliant with the spec, causing lots of confusion. The spec required a warning, because we do not specify flow dependent type inference of any kind. It's a slippery slope. We can review it in a future release. Set owner to @gbracha. |
Type promotion is in the language now (and has been for quite some time). |
Code following an 'is' check does not take into account the is check for the type.
The following generates warnings from dart2js and the old analyzer, but not the new one:
class Bar {
bool get isBar => true;
}
void check(Object f) {
// Warning here that isBar is not defined on Foo.
if (f is Bar && f.isBar) {
// Warning here too.
var b = f.isBar;
}
}
The text was updated successfully, but these errors were encountered: