www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18584] New: Undefined identifier when not specifying 'this'

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

          Issue ID: 18584
           Summary: Undefined identifier when not specifying 'this'
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

This program gives the error message 'undefined identifier n':

struct S {
    int n;
    auto fun() { return tmp!(a => n)(); }
}

struct tmp(alias fns) {
    alias fun = fns!int;
}

If you just add 'this', it works:

struct S {
    int n;
    auto fun() { return tmp!(a => this.n)(); }
}

struct tmp(alias fns) {
    alias fun = fns!int;
}

There should be no ambiguity here as to which 'n' I'm referring to, and 'this'
should be unnecessary.

--
Mar 09 2018