template instantiation
vit via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu May 19 13:14:48 PDT 2016
///Hello, i'm trying to implement d compiler and i've problems
with some template corner cases.
class Type{}
class Foo(T : const T){
alias X = T;
}
alias Bar(T : Foo!Ts, Ts...) = Ts[0];
pragma(msg, "Foo1: ", Foo!(immutable Type).X); //Foo1: Type
pragma(msg, "Foo2: ", Foo!(Type).X); //Foo2: Type
pragma(msg, "Bar: ", Bar!(Foo!(Type))); //Bar: immutable(Type)
Last pragma attempted to extract template parameters from
'Foo!(Type)' but since Foo!(immutable Type) == Foo!(Type) and
Foo!(immutable Type) was instantiated first, it extracted wrong
type.
If we change order of 1. and 2. pragma, result of 3. pragma will
be Type and not immutable(Type).
Is this a bug?
More information about the Digitalmars-d-learn
mailing list