D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1113 - Mixin causes incorrect static if branching
Summary: Mixin causes incorrect static if branching
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2007-04-08 17:10 UTC by Reiner Pope
Modified: 2014-02-16 15:22 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Reiner Pope 2007-04-08 17:10:58 UTC
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;
Comment 2 Don 2009-09-10 14:15:31 UTC
This was fixed in DMD1.020 or earlier.