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 case of use `augmented` constant in a control-flow collections `if` and `for` #57053

Open sgrekhov opened 2 weeks ago

sgrekhov commented 2 weeks ago

Any use of an augmented variable in an augmenting function is an error. But there are no expected errors in the analyzer in the code below.

const augmented = 1;

void topLevelFunction() {}

augment void topLevelFunction() {
  var map = {
    for (var i = 0; i > augmented;) i: i
//                      ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
  };
  var set = {
    if (1 > augmented) 42
//          ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
  };
}

Appropriate co19 test is https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmented_expression_A10_t21.dart