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.
Comment #1 by slavo5150 — 2018-03-10T06:20:29Z
Comment #2 by razvan.nitu1305 — 2018-04-10T13:25:46Z
Alternate attempted fix : https://github.com/dlang/dmd/pull/8159
Comment #3 by github-bugzilla — 2018-04-17T13:16:19Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/814b822011002fe89434f195597ed6a20042ce88 Fix Issue 18584 - Undefined identifier when not specifying 'this' https://github.com/dlang/dmd/commit/b4d5005db0fd3581789d8a0942583f7c13efbc82 Merge pull request #8159 from RazvanN7/Issue_18584 Fix Issue 18584 - Undefined identifier when not specifying 'this' merged-on-behalf-of: Razvan Nitu <[email protected]>
Comment #4 by github-bugzilla — 2018-04-18T08:53:58Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4c6794ff0e64e6c7fc6e78fd06bb69bdc82d6435 Use toAlias2 instead of toAlias - follow-up on Issue 18584 https://github.com/dlang/dmd/commit/4b37c3b0b989eeef4c53ae65f283b602745b1c40 Merge pull request #8185 from RazvanN7/Issue_18584_fixup Use toAlias2 instead of toAlias - follow-up on Issue 18584 merged-on-behalf-of: Jacob Carlborg <[email protected]>