[Issue 21862] New: Taking address of non-static method without "this" should not be allowed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 25 14:07:40 UTC 2021


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

          Issue ID: 21862
           Summary: Taking address of non-static method without "this"
                    should not be allowed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io

This should *not* compile, &S.m needs 'this' which is not available there:

    struct S {
        int m(int x) {return x;}
    }

    void main() {
        int function(int) func = &S.m;
        writeln(func(5));           // does not print 5!
    }

--


More information about the Digitalmars-d-bugs mailing list