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: no error when constant constructor redirects to non-constant #34509

Closed
eernstg opened this issue Sep 18, 2018 · 1 comment
Closed
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@eernstg
Copy link
Member

eernstg commented Sep 18, 2018

Consider the following program:

class A {
  final int i;
  const A(): this._(1);
  A._(this.i);
}

With dartanalyzer version 0.2.1-dev.4.0 this yields 'No issues', but it is a compile-time error for a constant constructor to redirect to a non-constant constructor (section 'Redirecting Generative Constructors'):

When $\ConstMetavar$ is \CONST{},
it is a compile-time error if the redirectee is not a constant constructor.

As an aside, the vm says 'A constant constructor can't call a non-constant constructor', so I believe that there is no need to create an area-meta issue for several tools.

@eernstg eernstg added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 18, 2018
@srawlins
Copy link
Member

srawlins commented Jun 8, 2020

An error is now reported:

error • Constant redirecting constructor can't redirect to a non-constant constructor. • 34509.dart:3:19 • redirect_to_non_const_constructor

@srawlins srawlins closed this as completed Jun 8, 2020
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. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants