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

[cfe] Excessive error if enum and another declaration have the same names #59623

Open
sgrekhov opened this issue Nov 27, 2024 · 1 comment
Open
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE.

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Nov 27, 2024

enum E {e1;} // CFE: Error: Couldn't find constructor 'E'. Analyzer: Ok

int E = 1; // CFE: Error: 'E' is already declared in this scope. Analyzer: The name 'E' is already defined

Why CFE reports an error on the enum declaration? There is nothing wrong with it. No this issue if to replace an enum by some class declaration (CFE reports an error for the second declaration only if the first declaration is a class).

Dart SDK version: 3.7.0-183.0.dev (dev) (Fri Nov 22 20:03:46 2024 -0800) on "windows_x64"

@sgrekhov sgrekhov added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Nov 27, 2024
@johnniwinther johnniwinther added cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE. and removed area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Nov 27, 2024
@lrhn
Copy link
Member

lrhn commented Nov 27, 2024

The actual error reported for the enum here does look spurious, as if the enum declaration can't find itself. That's not useful.

I would want an error at both declarations - they're both declarations with conflicted names and one being declared before the other doesn't change that. We don't know which one is wrong (or if it's both), but we do know that neither is valid because there is another declaration with the same name.
(That said, all the spec requires is "a compile-time error", meaning that we refuse to let the program run. Anything else is usability, not speciification.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE.
Projects
None yet
Development

No branches or pull requests

3 participants