Comment #0 by qs.il.paperinik — 2019-02-27T19:18:47Z
In this code
struct S
{
static int fImpl(Ret)() { return Ret.init; }
// tells us: `fImpl!int` is @system
pragma(msg, __traits(getFunctionAttributes, fImpl!int));
}
the function attributes should be @safe, pure, nothrow and @nogc.
Comment #1 by edi33416 — 2019-03-25T13:32:04Z
If you change the return type of your function to `auto`, pragma will output the expected `tuple("pure", "nothrow", "@nogc", "@safe")` function attributes.
What is more interesting is that even if you don't change the return type, you can safely call the function in a `@safe` function and the deduction is correct
```
struct S
{
static int fImpl(Ret)() { return Ret.init; }
@safe void bar() { fImpl!int(); }
}
```
Will compile just fine
Comment #2 by dlang-bot — 2023-04-25T09:35:08Z
@RazvanN7 created dlang/dmd pull request #15129 "Fix Issue 19706 - Attribute inference in struct fails" fixing this issue:
- Fix Issue 19706 - Attribute inference in struct fails
https://github.com/dlang/dmd/pull/15129
Comment #3 by dlang-bot — 2023-04-26T08:36:59Z
dlang/dmd pull request #15129 "Fix Issue 19706 - Attribute inference in struct fails" was merged into master:
- c0c4b07ff530e7209dd921e0d9082405d3cfe3bd by RazvanN7:
Fix Issue 19706 - Attribute inference in struct fails
https://github.com/dlang/dmd/pull/15129