www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19026] New: Aliasing an inner function gets context but


          Issue ID: 19026
           Summary: Aliasing an inner function gets context but aliasing a
                    member function through instance does not
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ali.akhtarzada gmail.com

Based on this forum thread:
https://forum.dlang.org/thread/hyforteterjqhgghpshw forum.dlang.org

Aliasing an inner function seems inconsistent with aliasing a member function
in that the former aliases the contexted function whereas the latter not:

void main() {
    struct S { void f() {} }
    S s;
    void f() {}

    alias inner = f;
    alias member = s.f;

    pragma(msg, typeof(&inner)); // delegate
    pragma(msg, typeof(&member)); // function

so inner() can be called but not member() as you get: Error: need this for f of
type void()

Jun 25 2018