4016 – const initializer cannot forward reference other const initializer

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4016 - const initializer cannot forward reference other const initializer
Summary: const initializer cannot forward reference other const initializer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2010年03月27日 05:45 UTC by Rainer Schuetze
Modified: 2014年02月15日 02:42 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2010年03月27日 05:45:37 UTC
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 Walter Bright 2010年05月10日 15:13:04 UTC
changeset 481
Comment 2 Don 2010年05月18日 12:17:54 UTC
Fixed DMD2.046.


AltStyle によって変換されたページ (->オリジナル) /