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 analyzer for empty factory constructor #42337

Closed
sgrekhov opened this issue Jun 15, 2020 · 1 comment
Closed

[NNBD] No error in analyzer for empty factory constructor #42337

sgrekhov opened this issue Jun 15, 2020 · 1 comment
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sgrekhov
Copy link
Contributor

class C {
  factory C.f() {}
}

main() {
  C c = new C.f();
}

The code above produces no error in analyzer with --enable-experiment=non-nullable

dartanalyzer --enable-experiment=non-nullable,nonfunction-type-aliases private_and_public_t01.dart
Analyzing private_and_public_t01.dart...
hint - This function has a return type of 'C', but doesn't end with a return statement. - private_and_public_t01.dart:34:3 - missing_return
hint - The value of the local variable 'c' isn't used. - private_and_public_t01.dart:38:5 - unused_local_variable
2 hints found.

In VM it is an error

dart --enable-experiment=non-nullable,nonfunction-type-aliases private_and_public_t01.dart
private_and_public_t01.dart:34:11: Error: A non-null value must be returned since the return type 'C' doesn't allow null.
- 'C' is from 'private_and_public_t01.dart'.
factory C.f() {}
        ^

Dart VM version: 2.9.0-15.0.dev (dev) (Thu Jun 11 10:03:39 2020 +0200) on "windows_x64"

@lrhn lrhn added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jun 15, 2020
@scheglov scheglov self-assigned this Jun 15, 2020
@scheglov
Copy link
Contributor

dart-bot pushed a commit that referenced this issue Jun 15, 2020
…tors.

Bug: #42337
Change-Id: I9209d7bf519ec61026ffe22bb05145e776e8517d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151344
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants