www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - template instantiation

reply vit <vit vit.vit> writes:
///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?
May 19 2016
parent tsbockman <thomas.bockman gmail.com> writes:
On Thursday, 19 May 2016 at 20:14:48 UTC, vit wrote:
 Is this a bug?
Yes. I've filed a report: https://issues.dlang.org/show_bug.cgi?id=16050
May 20 2016