Comment #0 by andrej.mitrovich — 2013-09-22T07:19:02Z
-----
mixin template Helpers(int x)
{
@disable void foo() { }
}
struct S
{
mixin Helpers!16;
}
void main()
{
S s;
s.foo();
}
-----
$ dmd test.d
test.d(14): Error: function test.S.Helpers!16.foo is not callable because it is annotated with @disable
Because of these diagnostics using a template mixin introduces a really bad user experience. The user shouldn't have to know that a struct implements a function using a mixin template. The diagnostic should be:
-----
test.d(14): Error: function test.S.foo is not callable because it is annotated with @disable
-----
Currently we're forced to use string mixins to achieve the same effect:
-----
string Helpers(int x)()
{
return q{
@disable void foo() { }
};
}
struct S
{
mixin(Helpers!16());
}
void main()
{
S s;
s.foo();
}
-----
$ dmd test.d
test.d(16): Error: function test.S.foo is not callable because it is annotated with @disable
But mixin templates are supposed to be used exactly for this purpose, for mixing in declarations rather than arbitrary code.
Comment #1 by robert.schadek — 2024-12-13T18:11:45Z