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] Incorrect nullability normalization of FutureOr in runtime type test #48937

Open
askeksa-google opened this issue May 2, 2022 · 0 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@askeksa-google
Copy link

import 'dart:async';

main() {
  List<Future<String?>?> l = [];
  f1(l);
  f2(l);
  print(l is List<FutureOr<String?>>);
  print(l is List<FutureOr<String?>?>);
}

void f1(List<FutureOr<String?>> l) {}
void f2(List<FutureOr<String?>?> l) {}

In the VM, this prints false for both runtime type tests, though it should print true for both.

A toString on a runtime type containing a FutureOr of a nullable type seems to never put a ? on the FutureOr type, so it looks like these types are normalized to be declared non-nullable and then erroneously treated as actually non-nullable in the subtype test.

@askeksa-google askeksa-google added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels May 2, 2022
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, 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