Inferred attributes errors in template function.
user1234
user1234 at 12.de
Fri May 27 09:41:32 UTC 2022
On Friday, 27 May 2022 at 08:39:08 UTC, vit wrote:
> Hello, I have this problem:
>
> ```d
> static int i;
>
> void bar(T)(){
> static if(is(T == int))
> (()@system => 1)();
> static if(is(T == float))
> i = 42;
>
> }
> void foo(T)(){
> bar!T();
> }
>
> void main()@safe pure{
> foo!long();
> foo!float(); //Error: `pure` function `D main` cannot call
> impure function `onlineapp.foo!float.foo`
> foo!int(); //Error: `@safe` function `D main` cannot call
> `@system` function `onlineapp.foo!int.foo`
> }
> ```
>
> [...]
on a side note that's funny how dmd manages to systematically
print the less interesting message in both case.
More information about the Digitalmars-d-learn
mailing list