dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

[augmentations] No error in the analyzer when the resulting constructor is not valid #57029

Open sgrekhov opened 2 weeks ago

sgrekhov commented 2 weeks ago

The code below has no expected error in the analyzer

class C {
  int x;
  C(this.x);
  C.foo(): this(0);
//^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C {
  augment C.foo(): x = 1;
}

main() {
  print(C);
}

The resulting constructor here is a redirecting constructor with a field initializer. It is a compile-time error.

Dart SDK version: 3.7.0-86.0.dev (dev) (Wed Oct 30 17:03:22 2024 -0700) on "windows_x64"