[Issue 3743] New: Forward reference problem with static if statements
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 26 13:31:38 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3743
Summary: Forward reference problem with static if statements
Product: D
Version: 1.055
Platform: All
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: adam.chrapkowski at gmail.com
--- Comment #0 from Adam Chrapkowski <adam.chrapkowski at gmail.com> 2010-01-26 13:31:37 PST ---
Forward reference fails when declaration is inside static if statement.
example:
//------------------------------------------------
const FOO_VER = 2;
static if(FOO_VER >= 2) // If Bar is defined
struct Bar { // Foo should be defined too.
Foo foo;
}
static if(FOO_VER >= 1)
struct Foo {
}
//------------------------------------------------
error: identifier 'Foo' is not defined
error: 'Foo' is used as a type
error: variable 'main.Bar.foo' voids have no value
The problem occurs for structures and classes, but not for functions:
The following work correctly:
//------------------------------------------------
static if(FOO_VER >= 2)
class Bar {
this(){ func(); };
}
static if(FOO_VER >= 1)
void func(){ }
//------------------------------------------------
static if(FOO_VER >= 2)
void func(){ Foo foo; }
static if(FOO_VER >= 1)
struct Foo {
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list