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 { }
Updating this bug. Note that this effects Aurora Graphics. The following will produce an 'undefined identifier' error in struct DWRITE_GLYPH_RUN on IDWriteFontFace static if(DX110) { public struct DWRITE_GLYPH_RUN { IDWriteFontFace fontFace; //Error: Undefined Identifier //... } } static if(DX111) { //...} static if(DX112) { //...} static if(DX110) { public interface IDWriteFontFace : IUnknown { HRESULT GetDesignGlyphMetrics(const(uint*) Indices, uint Count, DWRITE_GLYPH_METRICS* //... } } static if(DX111) { //...} static if(DX112) { //...}
I think I ran into this issue when I tried to import core.sys.posix.sys.types.off_t in core.stdc.stdio, for use in the fpos_t definition on linux. Commenting out the "static if" block around off_t fixed the issue, so it's definitely related to "static if" somehow.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18151 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB