0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 9.0.1569: cannot use "this.member" in lambda in class method

Problem:    Cannot use "this.member" in lambda in class method.
Solution:   Adjust check for reserved keyword. (Hirohito Higashi,
            closes #12416, closes #12076, closes #12336)
This commit is contained in:
h-east
2023-05-19 19:01:17 +01:00
committed by Bram Moolenaar
parent d49f646bf5
commit 2bd6a09691
6 changed files with 30 additions and 10 deletions

View File

@@ -856,6 +856,27 @@ def Test_class_member()
END
v9.CheckScriptSuccess(lines)
# access private member in lambda body
lines =<< trim END
vim9script
class Foo
this._x: number = 6
def Add(n: number): number
var Lam = () => {
this._x = this._x + n
}
Lam()
return this._x
enddef
endclass
var foo = Foo.new()
assert_equal(13, foo.Add(7))
END
v9.CheckScriptSuccess(lines)
# check shadowing
lines =<< trim END
vim9script