Bug 24559 – Compiler fails to error about using enum type as a value when compiling with -o-

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-05-23T18:15:13Z
Last change time
2024-12-13T19:35:18Z
Assigned to
No Owner
Creator
Eyal
Moved to GitHub: dmd#20456 →

Comments

Comment #0 by eyal — 2024-05-23T18:15:13Z
enum Flags : ubyte { Foo = 1, } void foo() { if(Flags) { // "Flags" as an expression should yield an error, but is only an error when generating object code, -o- succeeds } }
Comment #1 by contact — 2024-05-23T18:30:26Z
From what I investigated, semantics gags the error and defer that to e2ir glue code, hence it doesn't happen on `-o-`. We have two possible options: - We do the check for expressions with EXP.error after semantic3 and remove it from e2ir visitor; - Detect these situations when we encounter them. It seems expressionsem assumes its a forward reference and goes on, which to me, shouldn't.
Comment #2 by contact — 2024-05-23T18:31:24Z
Interesting enough, if you run `-verror=spec` with `-o-` it fails (enables display of error gagging on speculative compilations).
Comment #3 by robert.schadek — 2024-12-13T19:35:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20456 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB