Bug 4016 – const initializer cannot forward reference other const initializer

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-03-27T05:45:00Z
Last change time
2014-02-15T02:42:36Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2010-03-27T05:45:37Z
comipiling ---- const PM_QS_INPUT = QS_INPUT; const QS_INPUT = 2; ---- produces: test.d(1): Error: forward reference of variable QS_INPUT Here's a patch: Index: expression.c =================================================================== --- expression.c (revision 421) +++ expression.c (working copy) @@ -2395,7 +2395,9 @@ { //printf("Identifier '%s' is a variable, type '%s'\n", toChars(), v->type->toChars()); if (!type) - { type = v->type; + { if (!v->type && v->scope) + v->semantic(v->scope); + type = v->type; if (!v->type) { error("forward reference of %s %s", v->kind(), v->toChars()); type = Type::terror;
Comment #1 by bugzilla — 2010-05-10T15:13:04Z
changeset 481
Comment #2 by clugdbug — 2010-05-18T12:17:54Z
Fixed DMD2.046.