What am I doing wrong here?

Martin martinbbjerregaard at gmail.com
Sun Oct 14 06:46:15 PDT 2012


On Sunday, 14 October 2012 at 12:58:24 UTC, Simen Kjaeraas wrote:
> 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

Oh, thank you for clarifying, I thought I was doing something 
wrong :)


More information about the Digitalmars-d-learn mailing list