[Issue 21287] New: Delegate in global template can't call non-anonymous nested function passed as alias

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 30 19:44:02 UTC 2020


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

          Issue ID: 21287
           Summary: Delegate in global template can't call non-anonymous
                    nested function passed as alias
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

---
struct A {}

alias canMatch(alias handler) = (A arg) => handler(arg);

struct StructuralSumType
{
        void opDispatch()
        {
                void fun(Value)(Value _) {}
                alias lambda = (_) {};

                alias ok = canMatch!lambda;
                alias err = canMatch!fun;
        }
}
---

Compiler output as of DMD 2.093.1:

---
sumtype.d(3): Error: delegate sumtype.canMatch(alias handler) cannot access
frame of function sumtype.StructuralSumType.opDispatch
sumtype.d(13): Error: template instance `sumtype.canMatch!(fun)` error
instantiating
---

Possibly a duplicate of issue 15298, though the error messages are different.

--


More information about the Digitalmars-d-bugs mailing list