0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 9.0.1240: cannot access a private object member in a lambda

Problem:    Cannot access a private object member in a lambda defined inside
            the class.
Solution:   Go up the context stack to find the class. (closes #11866)
This commit is contained in:
Bram Moolenaar
2023-01-24 15:07:04 +00:00
parent b149d22796
commit 62a6923470
5 changed files with 35 additions and 1 deletions

View File

@@ -645,6 +645,24 @@ def Test_class_member()
END
v9.CheckScriptSuccess(lines)
# access private member in lambda
lines =<< trim END
vim9script
class Foo
this._x: number = 0
def Add(n: number): number
const F = (): number => this._x + n
return F()
enddef
endclass
var foo = Foo.new()
assert_equal(5, foo.Add(5))
END
v9.CheckScriptSuccess(lines)
# check shadowing
lines =<< trim END
vim9script