[Issue 1113] New: Mixin causes incorrect static if branching
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 8 15:10:59 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1113
Summary: Mixin causes incorrect static if branching
Product: D
Version: 1.010
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: reiner.pope at gmail.com
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;
--
More information about the Digitalmars-d-bugs
mailing list