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

[analyzer] No error for some duplicate top-level declarations in augment library #55113

Closed
sgrekhov opened this issue Mar 6, 2024 · 8 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Mar 6, 2024

According to the Augmentation library specification

It is a compile-time error if:

  • A top-level declaration in an augmentation has the same name as a declaration in the main library or another of its augmentations (unless it is an augmenting declaration, described below). This is the same error conceptually as having a name collision in one file.

But analyzer doesn't report errors for mixins, extensions and extension types. Example

// main_lib.dart
import augment 'aug_lib.dart';

class C {}

mixin M {}

enum E {e;}

void foo() {}

typedef void Foo();

typedef StringAlias = String;

int get getter => 42;

void set setter(int _) {}

extension Ext on List {}

extension type ET(int _) {}

var x = 0;

const c = 0;

main() {
  print(C);
  print(M);
  print(E);
  print(foo);
  print(Foo);
  print(StringAlias);
  print(getter);
  setter = 1;
  print(List);
  print(ET);
  print(x);
  print(c);
}

// aug_lib.dart
library augment 'main_lib.dart';

class C {} // Ok, error reported

mixin M {} // No error

enum E {e;} // Ok, error reported

void foo() {} // Ok, error reported

typedef void Foo(); // Ok, error reported

typedef StringAlias = String; // Ok, error reported

int get getter => 42; // Ok, error reported

void set setter(int _) {} // Ok, error reported

extension Ext on List {} // No error

extension type ET(int _) {} // No error

var x = 0; // Ok, error reported

const c = 0; // Ok, error reported

Tested using Dart SDK version: 3.4.0-edge.59035021cf3ceb5aecf4c85ba0affd1d6aab8fa6 (main) (Wed Mar 6 01:30:11 2024 +0000) on "linux_x64"

@sgrekhov sgrekhov added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature labels Mar 6, 2024
@scheglov scheglov added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Mar 6, 2024
@scheglov scheglov self-assigned this Mar 6, 2024
@bwilkerson
Copy link
Member

Any updates?

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 13, 2024
@pq
Copy link
Member

pq commented Mar 20, 2024

Friendly triage ping: any updates on this one?

1 similar comment
@srawlins
Copy link
Member

srawlins commented Apr 5, 2024

Friendly triage ping: any updates on this one?

@bwilkerson
Copy link
Member

@scheglov Any updates?

@scheglov
Copy link
Contributor

No.

@srawlins
Copy link
Member

Is this P1 for the Dart 3.4 release? Is it being worked on or should someone else take it on?

@scheglov scheglov added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 15, 2024
@scheglov
Copy link
Contributor

No, I downgraded it.

@sgrekhov
Copy link
Contributor Author

Retested on Dart SDK version: 3.6.0-edge.a6a2c57d689c5aca7d9fadd5dbf04615246ed198 (main) (Fri Sep 13 23:29:47 2024 +0000) on "linux_x64" (augmentation libraries replaced with parts in the code above). No this issue now. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
Development

No branches or pull requests

5 participants