January 26, 2010 [Issue 3743] New: Forward reference problem with static if statements | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: adam.chrapkowski@gmail.com --- Comment #0 from Adam Chrapkowski <adam.chrapkowski@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: ------- |
Copyright © 1999-2021 by the D Language Foundation