www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - recursive alias declaration

reply "Namespace" <rswhite4 googlemail.com> writes:
Did I miss something or is this a bug?

----
import std.stdio;

struct Rect(T) {
public:
	bool intersects(ref const Rect!T rhs, ShortRect* overlap = null) 
{
		return false;
	}
}

alias FloatRect = Rect!float;
alias ShortRect = Rect!short;

void main() {

}
----

print:
tpl_bug.d(11): Error: alias tpl_bug.ShortRect recursive alias 
declaration
tpl_bug.d(11): Error: template instance tpl_bug.Rect!(short) 
error instantiating
tpl_bug.d(10): Error: template instance tpl_bug.Rect!(float) 
error instantiating

dmd 2.063.2, Windows

Seems the Compiler is a bit confused. If I change 'ShortRect* 
overlap' to 'Rect!short' or 'Rect!T' everything works fine.
Jul 23 2013
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 07/23/2013 10:00 AM, Namespace wrote:
 Did I miss something or is this a bug?

 ----
 import std.stdio;

 struct Rect(T) {
 public:
      bool intersects(ref const Rect!T rhs, ShortRect* overlap = null) {
          return false;
      }
 }

 alias FloatRect = Rect!float;
 alias ShortRect = Rect!short;

 void main() {

 }
 ----

 print:
 tpl_bug.d(11): Error: alias tpl_bug.ShortRect recursive alias declaration
 tpl_bug.d(11): Error: template instance tpl_bug.Rect!(short) error
 instantiating
 tpl_bug.d(10): Error: template instance tpl_bug.Rect!(float) error
 instantiating

 dmd 2.063.2, Windows

 Seems the Compiler is a bit confused. If I change 'ShortRect* overlap'
 to 'Rect!short' or 'Rect!T' everything works fine.
Looks like a bug to me. Ali
Jul 23 2013