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

NNBD. No error in VM if optional non-nullable parameter has no default value #40954

Closed
sgrekhov opened this issue Mar 10, 2020 · 1 comment
Closed
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. NNBD Issues related to NNBD Release

Comments

@sgrekhov
Copy link
Contributor

According to the NNBD specification

It is an error if an optional parameter (named or otherwise) with no default value has a potentially non-nullable type except in the parameter list of an abstract method declaration.

In fact, analyzer reports this error but VM doesn't. For example, the following code works in VM without any error

class A {}

class C {
  static void test1(var v, [A a]) {}
//                            ^
// [analyzer] unspecified
// [cfe] unspecified

  static void test2(var v, {A a}) {}
//                            ^
// [analyzer] unspecified
// [cfe] unspecified

  void test11(var v, [A a]) {}
//                      ^
// [analyzer] unspecified
// [cfe] unspecified

  void test22(var v, {A a}) {}
//                      ^
// [analyzer] unspecified
// [cfe] unspecified
}

void test1(var v, [A a]) {}
//                   ^
// [analyzer] unspecified
// [cfe] unspecified

void test2(var v, {A a}) {}
//                   ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}

Dart VM version: 2.8.0-dev.12.0 (Thu Mar 5 11:45:50 2020 +0100) on "windows_x64"

@keertip keertip added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Mar 11, 2020
@alexmarkov alexmarkov added area-front-end Use area-front-end for front end / CFE / kernel format related issues. NNBD Issues related to NNBD Release and removed area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Mar 11, 2020
@a-siva
Copy link
Contributor

a-siva commented Mar 11, 2020

I believe this needs the --force-nnbd-checks guard in CFE to be removed which is tracked in #40980.
This issue can be closed a dup of that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

5 participants