On Tuesday, 26 March 2013 at 22:35:46 UTC, John Colvin wrote:
On Tuesday, 26 March 2013 at 21:28:16 UTC, Joseph Cassman wrote:
I get these errors

aggregate.d(11): Error: variable aggregate.A.c!("y").c cannot use template to add field to aggregate 'A' aggregate.d(6): Error: template instance aggregate.A.c!("y") error instantiating

from compiling the following code

struct A
{
   void b()
   {
       size_t y;
       mixin(c!("y"));
   }

   template c(string x)
   {
       const char[] c = "
           while(" ~ x ~ " < 100)
           {
               " ~ x ~ "++;
           }";
   }
}

I can only find bug 276 (http://d.puremagic.com/issues/show_bug.cgi?id=276) which seems related but looks like it was fixed.

I am using dmd 2.062 on Ubuntu Linux 12.10.

Is this a bug? Or maybe bad code?

Thanks

Joseph

It's bad code. What were you hoping for the code to do?

Sorry, I didn't read the code properly.

The template should be outside of the struct, then it works.

Reply via email to