[Issue 22694] New: template mixin with UDA not recognized inside function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 21 10:18:35 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22694

          Issue ID: 22694
           Summary: template mixin with UDA not recognized inside function
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: minor
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: htvennik at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list