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

VM incorrectly infers that value is non-nullable after 'is' check #40795

Closed
alexmarkov opened this issue Feb 26, 2020 · 0 comments
Closed

VM incorrectly infers that value is non-nullable after 'is' check #40795

alexmarkov opened this issue Feb 26, 2020 · 0 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@alexmarkov
Copy link
Contributor

alexmarkov commented Feb 26, 2020

Similar to #40792, but now in VM's optimizer.

import "package:expect/expect.dart";

dynamic result;

bar(x) {
  result = (x == null) ? 'null' : 'not null';
}

class A<S, T extends S> {
  @pragma('vm:never-inline')
  foo(S x) {
    if (x is T) {
      bar(x);
    }
  }
}

main(List<String> args) {
  for (int i = 0; i < 30001; ++i) {
    result = 'unexpected';
    new A<Null, Null>().foo(null);
    Expect.equals('null', result);
  }
}
out/ReleaseX64/dart foo.dart
Unhandled exception:
Expect.equals(expected: <null>, actual: <not null>) fails.
#0      Expect._fail (package:expect/expect.dart:682:5)
#1      Expect.equals (package:expect/expect.dart:123:7)
#2      main (file:///.../foo.dart:23:12)
#3      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
@alexmarkov alexmarkov added area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Feb 26, 2020
@alexmarkov alexmarkov self-assigned this Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

1 participant