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.3k stars 1.59k forks source link

[Augmentations] No error in analyzer for mixin and extension when augmentation is before original declaration #56287

Open sgrekhov opened 4 months ago

sgrekhov commented 4 months ago

The test https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01.dart checks that it is a compile-time error if augmentation location is before augmented declaration. It produce errors in the analyzer.

FAILED: dart2analyzer-none release_x64 co19/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01
Expected: Pass
Actual: MissingCompileTimeError

--- Command "dart2analyzer" (took 02.000766s):
DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/dart-sdk/bin/dart out/ReleaseX64/gen/dartanalyzer.dart.snapshot -Dtest_runner.configuration=analyzer-asserts-linux --enable-experiment=macros --ignore-unrecognized-flags --packages=/home/sgrekhov/Google/dart-sdk/sdk/.dart_tool/package_config.json --format=json /home/sgrekhov/Google/dart-sdk/sdk/tests/co19/src/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01.dart

static error failures:
- Missing expected unspecified error at tests/co19/src/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01_lib.dart line 24, column 7, length 1.

- Missing expected unspecified error at tests/co19/src/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01_lib.dart line 35, column 11, length 3.

- Missing expected unspecified error at tests/co19/src/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01_lib.dart line 40, column 16, length 2.

- Missing expected unspecified error at tests/co19/src/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01.dart line 59, column 22, length 3.

--- Re-run this test:
python3 tools/test.py -n analyzer-asserts-linux co19/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t01
[00:03 | 100% | +    0 | -    1]

Errors in augmenting_declarations_A02_t01_lib.dart looks like:

augment library  'augmenting_declarations_A02_t01.dart';

class C {}
//    ^
// [analyzer] unspecified
// [cfe] unspecified

mixin M {} // No expected DUPLICATE_DEFINITION error
//    ^
// [analyzer] unspecified
// [cfe] unspecified

enum E {e0;}
//   ^
// [analyzer] unspecified
// [cfe] unspecified

class A {}
extension Ext on A {} // No expected DUPLICATE_DEFINITION error
//        ^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(int _) {} // No expected DUPLICATE_DEFINITION error
//             ^^
// [analyzer] unspecified
// [cfe] unspecified

typedef StringAlias = String;
//      ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef void Foo();
//           ^^^
// [analyzer] unspecified
// [cfe] unspecified

Why these errors are not reported?

sgrekhov commented 4 months ago

Also https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t02.dart https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t03.dart for a setter