Jump to page: 1 2
Thread overview
[Issue 7815] New: Mixin template forward reference (?) regression
Apr 03, 2012
klickverbot
Apr 06, 2012
Walter Bright
Apr 07, 2012
David Simcha
Apr 08, 2012
David Simcha
Apr 08, 2012
Walter Bright
Apr 08, 2012
Walter Bright
Apr 08, 2012
Walter Bright
Apr 08, 2012
David Simcha
Apr 08, 2012
klickverbot
Apr 08, 2012
David Simcha
Apr 08, 2012
klickverbot
Apr 09, 2012
David Simcha
Apr 10, 2012
Walter Bright
Apr 11, 2012
klickverbot
Apr 11, 2012
Walter Bright
Apr 11, 2012
Walter Bright
Apr 11, 2012
Walter Bright
April 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815

           Summary: Mixin template forward reference (?) regression
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@klickverbot.at


--- Comment #0 from klickverbot <code@klickverbot.at> 2012-04-03 10:08:27 PDT ---
DMD 2.058 accepted the following snippet, while DMD c2824d43 executes the else branch of the static if. In there, though, instantiating the template will (apparently) just work fine.

---
mixin template Helpers() {
  alias typeof(this) This;

  static if (is(Flags!This)) {
    Flags!This flags;
  } else {
    // DMD will happily instantiate the allegedly
    // non-existent Flags!This here. (!)
    pragma(msg, __traits(derivedMembers, Flags!This));
  }
}

template Flags(T) {
  mixin({
    string defs;
    foreach (name; __traits(derivedMembers, T)) {
        defs ~= "bool " ~ name ~ ";\n";
    }
    if (defs.length > 0) {
      return "struct Flags {" ~ defs ~ "}";
    } else {
      return "";
    }
  }());
}

struct Move {
  int a;
  mixin Helpers!();
}

enum a = Move.init.flags; // isSetFlags should exist.
---

(Note that while the above code is probably not the minimal possible example needed to trigger the bug, it has been reduced beyond repair as far as its original intent goes, so don't try to make sense of it in that regard.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815



--- Comment #1 from github-bugzilla@puremagic.com 2012-04-05 21:07:38 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7a81d73021c456fd546cb241f40420717d2ec365 fix Issue 7815 - Mixin template forward reference (?) regression

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha@yahoo.com


--- Comment #2 from David Simcha <dsimcha@yahoo.com> 2012-04-07 15:52:59 PDT ---
I think the fix may have only fixed certain cases of this bug.  I'm running into another case of what looks to be the same bug using 2.059 beta 2, but I'm still working on reducing it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #3 from David Simcha <dsimcha@yahoo.com> 2012-04-07 17:22:21 PDT ---
I reduced the case where it's still failing, reopened.

enum Closure {
    Matrix
}

struct BasicMatrix {
    mixin Operand!( Closure.Matrix );
}

template Operand( Closure closure_ ) {
    alias closure_ closure;
}

struct Expression( string op_, Lhs, Rhs = void ) {
    enum lhsClosure = closureOf!Lhs;
}

template closureOf( T ) {
    enum closureOf = T.closure;
}

alias Expression!("+", BasicMatrix) Foo;


test.d(18): Error: no property 'closure' for type 'BasicMatrix'
test.d(14): Error: template instance test.closureOf!(BasicMatrix) error
instantiating
test.d(21):        instantiated from here: Expression!("+",BasicMatrix)
test.d(21): Error: template instance test.Expression!("+",BasicMatrix) error
instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815



--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-04-07 18:06:42 PDT ---
Please, the original two bugs were fixed and are fixed. A new bug should entered for new bugs, not reopening fixed ones. For next time.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |normal


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2012-04-07 18:18:42 PDT ---
This new case fails also on dmd 2.058, so it is not a regression.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815



--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2012-04-07 18:19:31 PDT ---
Reduced test case:
-----------------------
enum Closure {
    Matrix
}

struct BasicMatrix {
    mixin Operand!( Closure.Matrix );
}

template Operand( Closure closure_ ) {
    alias closure_ closure;
}

alias BasicMatrix.closure Foo;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #8 from David Simcha <dsimcha@yahoo.com> 2012-04-08 06:49:20 PDT ---
The fix that was just checked in fixes the test case I submitted but doesn't fix the bug in the code that I reduced the test case from.  I'm working on reducing another test case that still fails.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7815



--- Comment #9 from klickverbot <code@klickverbot.at> 2012-04-08 10:10:43 PDT ---
The original code I reduced the test case from still doesn't work either, will report a new bug once I managed to reduce it again.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2