Bug 23074 – premature enum type inference leads to spurious error message

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-30T23:44:18Z
Last change time
2024-12-13T19:22:30Z
Keywords
diagnostic
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#20094 →

Comments

Comment #0 by b2.temp — 2022-04-30T23:44:18Z
## test case ``` enum E { e1 = S.a } struct S { E e; enum a = "string"; } ``` ## output > /tmp/temp_7F3BFB9249F0.d:6:14: Error: cannot implicitly convert expression `"string"` of type `string` to `int` ## notes - if you change the initializer of `S.a` to an integer literal then the program compiles.
Comment #1 by b2.temp — 2022-04-30T23:56:27Z
semantic analysis of E members causes a semantic analysis of S, causing E to be visited again. a separate semantic analysis should be done for static/immutable/enum members, since they are just basically like module declarations.
Comment #2 by b2.temp — 2023-07-14T21:19:50Z
maybe at least the circular reference could be detected. That'd give a better error message.
Comment #3 by robert.schadek — 2024-12-13T19:22:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20094 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB