www.digitalmars.com         C & C++   DMDScript  

D - bug : template bugs (DMD 0.77)

New template syntax suger is very sweet! I take a liking for it.
And I found some template bugs.

1. when both '!' and 'instance' use , compiler will crash.

eg.
instance foo!(int) f;

2. '!' is not equivalent 'instance' key word.

A)
eg.
template foo(T) {}
alias foo!(int) foo;   // not ok
instance.foo(int) foo; // ok

maybe it is a good change , but error message is too complicated 
like this:
: instance foo(int) foo is not a template declaration

There is no line number and no file name where the error occurs.

B)
eg.
template Bar(T) {
void put() {}
}

Bar!(char[]) bar;    		// not ok
//	error: instance Bar(char[]) is used as a type

instance Bar(char[]) bar;	// ok

bar.put();

Of course , it is also written by using '!' as :
alias Bar!(char[]) bar;

However the former is much better , I think.

3.illegal typeof craches the compiler.

eg.
template Bar(T) { T t; }
typeof(Bar!(int)) bar; // illegal syntax
typeof(Bar!(int).t) bar; // ok

compiler will crash.

yaneurao.
Jan 03 2004