Skip to content

Prefix names are lexically scoped. #32248

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

Closed
lrhn opened this issue Feb 20, 2018 · 3 comments
Closed

Prefix names are lexically scoped. #32248

lrhn opened this issue Feb 20, 2018 · 3 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@lrhn
Copy link
Member

lrhn commented Feb 20, 2018

The analyzer is treating prefix names as special in some cases and lexically scoped in other cases.
It should treat the prefix name as lexically scoped in all cases, so:

import "dart:core" as prefix;
class C {
  var prefix = 42;
  prefix.int get foo => this.prefix;  // prefix in prefix.int should not refer to the import.
}

See #32200 for more detail.

@lrhn lrhn added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Feb 20, 2018
@bwilkerson bwilkerson added this to the Dart2.1 milestone Sep 2, 2018
@bwilkerson bwilkerson modified the milestones: Dart2.1, PostDart2.1 Sep 4, 2018
@aadilmaan aadilmaan modified the milestones: Future, D25 Release Jun 4, 2019
@eernstg
Copy link
Member

eernstg commented Sep 13, 2019

Note that #38373 reports another situation where the analyzer resolves a name in a type as a prefix, even though the same name is declared in nearer a lexical scope (also as an instance member).

@srawlins srawlins added the dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 17, 2020
@srawlins
Copy link
Member

The analyzer now reports this error:

error • The prefix 'prefix' can't be used here because it is shadowed by a local declaration. • a.dart:4:3 • prefix_shadowed_by_local_declaration

So I think this has been fixed?

@eernstg
Copy link
Member

eernstg commented Jan 11, 2021

I agree.

@scheglov, I'll close this issue—please reopen it if you think there are any remaining issues with lexical scoping and import prefixes.

@eernstg eernstg closed this as completed Jan 11, 2021
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. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants