[Issue 23815] closure allocated even if the escape is only used to access static members

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 29 21:42:28 UTC 2023


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

Salih Dincer <salihdb at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |salihdb at hotmail.com

--- Comment #1 from Salih Dincer <salihdb at hotmail.com> ---
No problem, the code compiles for me:

alias T = int;

class C
{
  static T i;
  this(T n) { i = n; }
}

alias fo = T function();  // not compile
alias foo = T delegate(); // compile

auto ID(C c)
{
  foo f = () => c.i;
  return f();
}

void main()
{
  auto test = new C(42);
  assert(test.ID == 42);
}

--


More information about the Digitalmars-d-bugs mailing list