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 accepts potentially-const expressions in const contructor invocations #36215

Open
MichaelRFairhurst opened this Issue Mar 14, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@MichaelRFairhurst
Copy link
Contributor

MichaelRFairhurst commented Mar 14, 2019

Analyzer accepts this:

class C {
  Object inner;
  const C(int x) : inner = const C(x);
}

This should not be accepted: x is not a constant expression. It is merely a potentially constant expression.

Proof by contradiction:

var x;
print(new C(x));

By using new, inner cannot be initialized to a const C of x, because x is not const.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.