Compiler Error while using Validation in the hunt-framework

Steven Schveighoffer schveiguy at gmail.com
Thu Oct 20 13:24:00 UTC 2022


On 10/19/22 3:00 PM, Roman Funk wrote:
> Hello,
> 
> I started playing with D and the hunt-framework. But I bumped into an 
> error using Validation.
> 
> ```d
> module app.forms.LoginForm;
> import hunt.validation;
> import hunt.framework.http.Form;
> 
> class LoginForm : Form {
>      mixin MakeForm;
>      @Email
>      string name;
>      @Length(3,8)
>      string password;
> }
> 
> ```
> The error looks like that:
> 
> `../hunt/validation/DeclDef.d-mixin-41(54,108): Error: undefined 
> identifier arg`
> 
> When I remove the parameters from `@Length`, it compiles.
> 
> I tried the `dicoth` example application, but I get the same error for 
> the validation used there.
> 
> I use this compiler: DMD64 D Compiler v2.100.2
> under Linux.
> 
> My current D knowledge is not sufficient to fix the bug. No idea how the 
> annotation and mixin templates work together here. I didn't find any 
> documentation, how to write custom annotations.
> 
> Can somebody give me a hint?

Just a thought, this may be nothing as I've never used the hunt 
framework, but try putting the mixin at the end of the class. Sometimes 
mixins can introspect the type they are being mixed into, which means 
the compiler has to build the rest of the type *first*. Although D 
should be able to forward reference all of this, at some point you have 
to have some kind of ordering in order to properly introspect a partly 
built type.

-Steve


More information about the Digitalmars-d-learn mailing list