Given the following declarations
------------------
mixin template Foo(T)
{
struct S
{
T a;
}
}
enum myUda;
------------------
The following code does not compile:
------------------
int main()
{
@myUda
mixin Foo!int;
auto s = S(0);
return s.a;
}
------------------
Error: found `Foo` when expecting `(` following `mixin`
However, the following two snippets compile successfully:
------------------
int main()
{
mixin Foo!int;
auto s = S(0);
return s.a;
}
------------------
@myUda
mixin Foo!int;
int main()
{
auto s = S(0);
return s.a;
}
------------------
Looks like dmd fails to recognize a template mixin inside a function when it has an UDA applied to it.
Comment #1 by jlourenco5691 — 2022-01-21T20:45:45Z
Not just inside function blocks, but unittest blocks too.
Comment #2 by robert.schadek — 2024-12-13T19:20:31Z