Skip to content
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

Closed
blois opened this issue May 21, 2013 · 7 comments
Closed

dart2js type warning following is check #10776

blois opened this issue May 21, 2013 · 7 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@blois
Copy link
Contributor

blois commented May 21, 2013

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;
  }
}

@DartBot
Copy link

DartBot commented May 21, 2013

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.

@blois
Copy link
Contributor Author

blois commented May 21, 2013

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.

@DartBot
Copy link

DartBot commented May 21, 2013

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.
cc @johnniwinther.

@blois
Copy link
Contributor Author

blois commented May 21, 2013

So this is what the code should be?

if (f is Bar) {
  Bar b = f;
  if (b.isBar) {
    b.doSomething();
  }
}

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.

@DartBot
Copy link

DartBot commented May 22, 2013

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.
Removed Area-Dart2JS label.
Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented May 22, 2013

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.
Removed Type-Defect label.
Added Type-Enhancement, Accepted labels.

@blois blois added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels May 22, 2013
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@munificent
Copy link
Member

Type promotion is in the language now (and has been for quite some time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants