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

Can't compare things against null in asserts in const constructors #34180

Closed
Hixie opened this issue Aug 18, 2018 · 2 comments
Closed

Can't compare things against null in asserts in const constructors #34180

Hixie opened this issue Aug 18, 2018 · 2 comments
Assignees
Labels
analyzer-constants 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)
Milestone

Comments

@Hixie
Copy link
Contributor

Hixie commented Aug 18, 2018

This fails in the analyzer with a CONST_EVAL_TYPE_BOOL_NUM_STRING:

class Test { }

class Foo {
  const Foo({
    this.test,
  }) : assert(test == null); // In constant expressions, operands of this operator must be of type 'bool', 'num', 'String' or 'null'.
  final Test test;
}

void main() { }
@lrhn
Copy link
Member

lrhn commented Aug 19, 2018

Constant expression were changed in the specification for Dart 2 so that this should be allowed.
(The old "e1 == e2 is constant if" were updated to also say "or e1 or e2 is null").

@lrhn lrhn 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 Aug 19, 2018
@bwilkerson bwilkerson added this to the Dart2.1 milestone Aug 28, 2018
@scheglov scheglov self-assigned this Sep 5, 2018
@scheglov
Copy link
Contributor

scheglov commented Sep 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-constants 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

4 participants