Bug 3723 – Regression: forward referenced enum

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2010-01-19T08:44:00Z
Last change time
2014-04-18T09:12:06Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2010-01-19T08:44:58Z
This code worked on 1.053, fails to compile on 1.054, and on D2. I suspect this was caused by the fix to bug 3611. ----- FwdEnum this_fails; enum :int { E1 = 2 } enum FwdEnum: int { E2 = E1 } ----- bug.d(10): Error: undefined identifier E1
Comment #1 by clugdbug — 2010-01-19T21:43:23Z
The regression is caused by this addition to Type *TypeEnum::toBasetype(). Knowing this doesn't necessarily help in fixing the problem, though. Type *TypeEnum::toBasetype() { + if (sym->scope) + { + sym->semantic(NULL); // attempt to resolve forward reference + }
Comment #2 by clugdbug — 2010-01-20T11:31:37Z
I've fixed this by changing the code in mtype.c, line 5984: Type *TypeEnum::toBasetype() { if (sym->scope) { - sym->semantic(NULL); // attempt to resolve forward reference + sym->trySemantic(NULL); // attempt to resolve forward reference } and adding this code to enum.c: void EnumDeclaration::trySemantic(Scope *sc) { unsigned errors = global.errors; global.gag++; DsymbolTable *savetable = symtab; semantic(sc); global.gag--; if (errors != global.errors) { global.errors = errors; symtab = savetable; } }
Comment #3 by bugzilla — 2010-01-24T15:02:43Z
Changeset 353
Comment #4 by bugzilla — 2010-01-30T22:42:12Z
fixed dmd 1.056 and 2.040