What am I doing wrong here?

Simen Kjaeraas simen.kjaras at gmail.com
Sun Oct 14 05:57:55 PDT 2012


On 2012-10-14, 14:28, Martin wrote:

> Hey everyone, I'm new to D so bare with me please. I've been trying to  
> figure out what's up with the strange forward refernce errors the  
> compiler (DMD 2.060) is giving me. Here's a code snippet that's  
> generating a forward reference error:
>
> public class AliasTestClass(alias func)
> {
> 	
> 	static assert(__traits(isStaticFunction, func));
> 		
> }
>
> public class TestClass
> {
> 	
> 	private AliasTestClass!(randomFunction) test; // <-----
> 		
> 	public static void randomFunction()
> 	{
> 	}
> 	
> }
>
> The strange part about it is that if I surround the randomFunction  
> parameter with another pair of paranthesis like so
>
> private AliasTestClass!((randomFunction)) test;
>
> It works just fine. If I don't, however, I get a forward reference error:
> "Error: template instance main.AliasTestClass!(randomFunction) forward  
> reference of randomFunction"
>
> Am I doing anything wrong or is this some kind of bug?

It's a bug. Maybe it's already in Bugzilla (there are some forward-ref
bugs there already). Please file:

http://d.puremagic.com/issues/enter_bug.cgi

-- 
Simen


More information about the Digitalmars-d-learn mailing list