Bug 18584 – Undefined identifier when not specifying 'this'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2018-03-09T14:24:28Z
Last change time
2018-04-18T08:53:58Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2018-03-09T14:24:28Z
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.