Bug 1113 – Mixin causes incorrect static if branching
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-04-08T17:10:00Z
Last change time
2014-02-16T15:22:49Z
Keywords
wrong-code
Assigned to
nobody
Creator
reiner.pope
Comments
Comment #0 by reiner.pope — 2007-04-08T17:10:58Z
The following code fails:
template Foo()
{
mixin("alias char[] TheType;");
static if (is(TheType : char[]))
static assert(true);
else
static assert(false);
}
alias Foo!() instance1;
mixins1.d(7): static assert is false
The following similar programs all compile:
// 1. Replace the mixin with the statement itself
template Foo()
{
alias char[] TheType;
static if (is(TheType : char[]))
static assert(true);
else
static assert(false);
}
alias Foo!() instance1;
// 2. Add a dummy declaration at the beginning of the template
template Foo()
{
char[] dummy;
mixin("alias char[] TheType;");
static if (is(TheType : char[]))
static assert(true);
else
static assert(false);
}
alias Foo!() instance1;
// 3. Replace static if with static assert
template Foo()
{
mixin("alias char[] TheType;");
static assert(is(TheType : char[]));
}
alias Foo!() instance1;