alias and __VERSION__ condition doesn't play well

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 19 04:15:54 UTC 2022


On 1/18/22 7:19 AM, vit wrote:
> On Tuesday, 18 January 2022 at 12:05:38 UTC, Paul Backus wrote:
>> On Tuesday, 18 January 2022 at 04:42:45 UTC, frame wrote:
>>> At the very top of my module I have this declaration:
>>>
>>> ```d
>>> static if (__VERSION__ >= 2098)
>>> {
>>>     alias Foo = TypeA;
>>> }
>>> else
>>> {
>>>     alias Foo = TypeB;
>>> }
>>> ```
>>>
>>> No problem inside the module itself but this doesn't work when 
>>> imported from another module:
>>> Error: undefined identifier `Foo`
>>
>> Works for me: https://run.dlang.io/is/XZlvQ8
> 
> It works until you have cyclic dependencies:
> 
> https://run.dlang.io/is/wDDcK5

Has nothing to do with `__VERSION__`:

https://run.dlang.io/is/pa8lDy

That does seem like a bug. And it's LDC specific, dmd seems to work fine.

-Steve


More information about the Digitalmars-d-learn mailing list