Skip to content

Analyzer: no error for using assertions in redirecting generative constructors #37867

Closed
@LongCatIsLooong

Description

@LongCatIsLooong

On dartPad or with my local SDK, the following code snippet does not trigger an analyzer warning/error, but fails to compile:

void main() {
  print(A.half(4));
}

class A {
  final int x;
  A(this.x);
  A.half(int x):
    assert(x % 2 == 0),
    this(x ~/ 2);
}

dart --version:

Dart VM version: 2.5.0-dev.1.0.flutter-0ca1582afd (Thu Jul 25 23:50:46 2019 +0000) on "linux_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions