-
Notifications
You must be signed in to change notification settings - Fork 27
is / as checks unnecessarily fail at runtime #524
Comments
@leafpetersen thoughts on the right behavior here? |
Oh shoot, we need a to do something here. Here's my sense. Most consistent/easiest to implement in the short term: it should be a warning like DownCastComposite. Medium-to-long term, maybe we can make progress on "no reified dynamic" direction, and we can have VM subtype rule consistent with DDC, making all of these "composite casts" a non issue. |
This is coming up in package:unittest. @nex3 fixed a strong mode error, but the new code (see util.dart) introduces |
Oh: we should fix this in DDC for sure, if Dart 1 and 2 checks would agree, we shouldn't throw. |
If we give a warning, it should only be on doing an typedef String StringIt(x);
typedef bool BoolIt(x);
void test(f) {
if (f is StringIt) {
foo(f);
} else if (f is BoolIt) {
bar(f);
}
} |
okay we chatted about this :). It sounds like Leaf may want to try attacking this from the Analyzer side. I'll assign to you Leaf for now. @vsmenon -- is this a P1? |
Just a note on this. The VM doesn't actually implement is checks correctly per the spec for function types. The code below passes checked mode and prints true: it should do neither per the spec. typedef To Function2<From, To>(From x);
typedef To Function2Opt<From, To>([From x]);
int f(int g([int y])) => g(3);
int g(int q(int y)) => q(3);
void main() {
Function2<Function2<int, int>, int> f2 = f;
Function2<Function2Opt<int, int>, int> f3 = g;
print(g is Function2<Function2Opt<int, int>, int>);
} |
the DDC runtime returns null when a difference from the spec mode result is possible. Fixes dart-archive/dev_compiler#524 . BUG= R=jmesserly@google.com, vsm@google.com Review URL: https://codereview.chromium.org/1945113003 .
This test throws a strong mode error at runtime. No static errors or warnings.
The text was updated successfully, but these errors were encountered: