Re: Inferred attributes errors in template function.

2022-05-27 Thread user1234 via Digitalmars-d-learn
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!lon

Re: Inferred attributes errors in template function.

2022-05-27 Thread Tejas via Digitalmars-d-learn
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!lon

Re: Inferred attributes errors in template function.

2022-05-27 Thread Paul Backus via Digitalmars-d-learn
On Friday, 27 May 2022 at 08:39:08 UTC, vit wrote: Is in dmd some flag that print errors similarly to this?: ```d void main()@safe pure{ foo!long(); foo!float(); //Error: `pure` function `D main` cannot call impure function `onlineapp.foo!float.foo` //Error: potent

Re: Inferred attributes errors in template function.

2022-05-27 Thread user1234 via Digitalmars-d-learn
On Friday, 27 May 2022 at 09:41:32 UTC, user1234 wrote: [...] on a side note that's funny how dmd manages to systematically print the less interesting message in both case. They are actually correct, I dont know why at some point I thought there was a problem. For the float one it's oviousl