Bug 9143 – template structs with two parameters confuse DMD on multiple instantiations

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-11T11:09:00Z
Last change time
2012-12-17T08:14:59Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
puneet

Comments

Comment #0 by puneet — 2012-12-11T11:09:19Z
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)(); }
Comment #1 by puneet — 2012-12-12T11:34:05Z
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(); }
Comment #2 by puneet — 2012-12-12T11:36:08Z
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.
Comment #3 by k.hara.pg — 2012-12-12T20:12:21Z