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

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.