Skip to content

Can't use a 'version' that was set inside 'static if' #18407

@dlangBugzillaToGithub

Description

@dlangBugzillaToGithub

Nick Sabalausky reported this on 2012-01-28T03:56:26Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=7386

CC List

  • Dennis
  • Iain Buclaw (@ibuclaw)
  • KytoDragon

Description

static if(true)
	version = Foo;
version(Foo) {}

test.d(2): Error: version Foo defined after use

The compiler's evaluation seems to occur in the wrong order ("versions before static ifs" instead of "top to bottom"), because this works:

static if(true)
	version = Foo;
static if(true)
	version(Foo) {}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions