Bug 19158 – declaration is already defined in another scope in main at line

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-08-11T16:27:17Z
Last change time
2021-07-19T00:22:29Z
Assigned to
No Owner
Creator
Ali Ak

Comments

Comment #0 by ali.akhtarzada — 2018-08-11T16:27:17Z
void main() { { struct S {} } { struct S {} } } Produces onlineapp.d(8): Error: declaration onlineapp.main.S is already defined in another scope in main at line 5 It should be possible to do this as they are in different scopes and should've be different than declaring a variable in different scopes. Issue 18266 was resolved but only "half" fixed - i.e. the ICE part. So I'm creating this one to keep track of the other half of that issue.
Comment #1 by ali.akhtarzada — 2018-08-11T16:29:28Z
*should be no different than...
Comment #2 by kytodragon — 2021-07-16T20:29:00Z
I would like to add, that this also blocks the usage of multiple static variables with the same name inside one function, not just type definitions. void main() { { __gshared int x = 0; } { __gshared float x = 1; } } This is used by libraries like Dear ImGui.
Comment #3 by moonlightsentinel — 2021-07-18T13:49:10Z
Fixed in 2.096.1
Comment #4 by pro.mathias.lang — 2021-07-19T00:22:29Z
For reference, this was a duplicate of issue 14831.