Thread overview
[Issue 9143] New: template structs with two bool parameters confuse DMD
Dec 11, 2012
Puneet Goel
[Issue 9143] template structs with two parameters confuse DMD on multiple instantiations
Dec 12, 2012
Puneet Goel
Dec 12, 2012
Puneet Goel
Dec 13, 2012
Kenji Hara
Dec 17, 2012
Walter Bright
December 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9143

           Summary: template structs with two bool parameters confuse DMD
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: puneet@coverify.org


--- Comment #0 from Puneet Goel <puneet@coverify.org> 2012-12-11 11:09:19 PST ---
The following code does not compile. But starts compiling once the first line of function noCall is commented out and the next two line which are logically equivalent are uncommented.

It seems compile time parameters of type bool are not propagated well by symbols in certain situations.

struct Foo (bool S, bool L) {
  auto noCall() {
    Foo!(S, false) x;        // compiles if this line commented
    // static if(S) Foo!(true, false) x;
    // else         Foo!(false, false) x;
  }
  this (T) (T other)        // constructor
  if (is (T unused == Foo!(P, Q), bool P, bool Q)) { }
}

void main() {
  Foo!(false, true) k = Foo!(false, false)();
}

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



--- Comment #1 from Puneet Goel <puneet@coverify.org> 2012-12-12 11:34:05 PST ---
Earlier I thought the problem occurs for bool parameters. But it seems to be more generic.

A more interesting test case:
1. Line 7 fails to compile.
2. There is no problem with line 4, 5, and 6.
3. If we uncomment line 3, compiler does not complain even for line 7.

struct Foo (bool L, size_t N) {
  void baaz () {
    // bar!(Foo!(false, 2LU))(); // line 3
    // bar!(Foo!(true, 2LU))();  // line 4
    // bar!(Foo!(L, N))();       // line 5
    // bar!(Foo!(true, N))();    // line 6
    bar!(Foo!(false, N))();      // line 7
  }
  void bar (T) ()
    if (is(T unused == Foo!(_L, _N), bool _L, size_t _N))
      {}
}

void main() {
  auto p = Foo!(true, 2LU)();
  p.baaz();
}

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


Puneet Goel <puneet@coverify.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker


--- Comment #2 from Puneet Goel <puneet@coverify.org> 2012-12-12 11:36:08 PST ---
Since the problem seems to be more generic than I initially reported, and because I am not finding any workarounds now, I am retagging the bug as blocker.

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-12 20:12:21 PST ---
https://github.com/D-Programming-Language/dmd/pull/1368

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


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: -------