Bug 7605 – Better error message when variable declaration hides type declaration
Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-28T09:22:00Z
Last change time
2012-02-28T15:34:15Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2012-02-28T09:22:11Z
module test;
struct Foo { }
void main()
{
Foo x;
int Foo;
Foo y; // Error: Foo is used as a type
}
Compare the above to this:
module a;
int Foo;
module b;
struct Foo { }
module main;
import a;
import b;
void main() {
Foo m;
}
main.d(7): Error: a.Foo at a.d(2) conflicts with b.Foo at b.d(2)
main.d(7): Error: Foo is used as a type
The first code example could instead output:
test.d(8): Error: test.Foo at test.d(3) conflicts with test.Foo at test.d(7)
test.d(8): Error: Foo is used as a type
Comment #1 by bugzilla — 2012-02-28T15:34:15Z
But it doesn't conflict. They are in different scopes, one nested inside the other. The nested one overrides the outer one - not conflicts with it.