[Issue 3072] tuples can't be aliases ( except when the aliases are templates. )
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Feb 22 20:58:47 PST 2015
https://issues.dlang.org/show_bug.cgi?id=3072
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Rob Jacques from comment #1)
> In general template tuples can't contain alias template parameters but it
> appears that there is an exception to this rule when the parameter is itself
> a template.
>
> DMD 2.049
>
> T foo(T)(T t) { return t; }
> template map1(fun...) {
> enum map1 = 42;
> }
> template map2(T, U...) {
> static if(U.length > 0) enum map2 = map2!(U);
> else enum map2 = 42;
> }
>
> void main() {
> auto x = map1!(char,foo); // compiles
> auto y = map2!(char,foo); // doesn't compile
> auto z = map1!(char,map1); // compiles
> auto w = map2!(char,map1); // doesn't compile
> return;
> }
>
> I've added the accepts-invalid, rejects-valid and spec keywords, since
> tuples of aliases should either work or not-work and the behavior should be
> documented in the spec. I'd lean towards not-work, since tuples of aliases
> seem to be buggy (i.e. Issue 5087) not to mention that alias parameters are
> buggy(i.e. issue 5082)
This test case is invalid. map2 is recursively instantiated, but in the line:
> static if(U.length > 0) enum map2 = map2!(U);
the instantiation map2!(foo) or map2!(map1) fails because any template symbols
cannot match to the type parameter T.
--
More information about the Digitalmars-d-bugs
mailing list