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

Analyzer treats tear-off of a constant constructor as not a constant #46899

Closed
sgrekhov opened this issue Aug 13, 2021 · 1 comment
Closed

Analyzer treats tear-off of a constant constructor as not a constant #46899

sgrekhov opened this issue Aug 13, 2021 · 1 comment
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sgrekhov
Copy link
Contributor

The following code works well in CFE but fails in analyzer

class C {
  const C();
  const C.named();
}

main() {
  const c1 = C.new;    // Analyzer error - Const variables must be initialized with a constant value
  const c2 = C.named;  // Analyzer error - Const variables must be initialized with a constant value
}

Tested on Dart SDK version: 2.15.0-edge.b2b8e59b2863ef02709dfdb750e9ae8e3732389c (be) (Fri Aug 13 01:08:51 2021 +0000) on "windows_x64"

@sgrekhov sgrekhov added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Aug 13, 2021
@lrhn lrhn added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Aug 13, 2021
@lrhn
Copy link
Member

lrhn commented Aug 13, 2021

The constructor doesn't even need to be declared const, any non-instantiated constructor tear-off is constant.

@jcollins-g jcollins-g added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Aug 17, 2021
@jcollins-g jcollins-g removed the type-enhancement A request for a change that isn't a bug label Aug 17, 2021
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. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants