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

patch 9.0.1041: cannot define a method in a class

Problem:    Cannot define a method in a class.
Solution:   Implement defining an object method.  Make calling an object
            method work.
This commit is contained in:
Bram Moolenaar
2022-12-09 21:41:48 +00:00
parent 148bcd3610
commit ffdaca9e6f
17 changed files with 267 additions and 86 deletions

View File

@@ -130,12 +130,19 @@ def Test_class_basic()
class TextPosition
this.lnum: number
this.col: number
def ToString(): string
return $'({this.lnum}, {this.col})'
enddef
endclass
# use the automatically generated new() method
var pos = TextPosition.new(2, 12)
assert_equal(2, pos.lnum)
assert_equal(12, pos.col)
# call an object method
assert_equal('(2, 12)', pos.ToString())
END
v9.CheckScriptSuccess(lines)
enddef