You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To add to this, consider the following code:
import std.algorithm;
struct Foo
{
static int fun(int n)
{
return n + 1;
}
}
void main()
{
int[10] arr;
Foo foo;
arr[].map!(n => foo.fun(n));
}
the line
arr[].map!(n => foo.fun(n));
causes GC allocation, whereas the same line with foo replaced with its type
arr[].map!(n => Foo.fun(n));
does not. This is despite the functionality being absolutely identical as fun has no dependency on 'this' whatsoever due to being a static member.
timon.gehr reported this on 2017-09-04T10:01:46Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=17804
CC List
Description
struct S{ enum n=1; } struct T{ static n=1; } void foo(S v)@nogc{ auto f=()=>v.n; // error } void bar(T v)@nogc{ auto f=()=>v.n; // error } This code should compile. Also see issue 17800.The text was updated successfully, but these errors were encountered: