class MyClass(T) : Base if (ConstraintExpression) {} compilation error

Maxim Fomin maxim at maxim-fomin.ru
Fri May 24 08:37:55 PDT 2013


On Friday, 24 May 2013 at 14:49:24 UTC, ref2401 wrote:
> Version D 2.062
>
> Please explain what is causing the error
>
> class Base
> { }
>
> class Class(T) : Base
> if (is(T == int))
> { }
>
> Error: unrecognized declaration
> Error: members expected
> Error: Declaration expected, not 'if'
> Error: { } expected following aggregate declaration

because dmd acts as grammar nazi:

ClassTemplateDeclaration: class Identifier ( 
TemplateParameterList ) Constraintopt BaseClassListopt ClassBody


More information about the Digitalmars-d-learn mailing list