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

patch 9.0.1724: vim9class constructor argument type checking bug

Problem: vim9class constructor argument type checking bug
Solution: fix it

closes: #12816

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: h-east <h.east.727@gmail.com>
This commit is contained in:
h-east
2023-08-16 21:49:54 +09:00
committed by Christian Brabandt
parent 5a0dd71ed9
commit 2261c89a49
5 changed files with 108 additions and 7 deletions

View File

@@ -518,6 +518,83 @@ def Test_class_default_new()
v9.CheckScriptFailure(lines, 'E119:')
enddef
def Test_class_new_with_object_member()
var lines =<< trim END
vim9script
class C
this.str: string
this.num: number
def new(this.str, this.num)
enddef
def newVals(this.str, this.num)
enddef
endclass
def Check()
try
var c = C.new('cats', 2)
assert_equal('cats', c.str)
assert_equal(2, c.num)
c = C.newVals('dogs', 4)
assert_equal('dogs', c.str)
assert_equal(4, c.num)
catch
assert_report($'Unexpected exception was caught: {v:exception}')
endtry
enddef
Check()
END
v9.CheckScriptSuccess(lines)
lines =<< trim END
vim9script
class C
this.str: string
this.num: number
def new(this.str, this.num)
enddef
endclass
def Check()
try
var c = C.new(1, 2)
catch
assert_report($'Unexpected exception was caught: {v:exception}')
endtry
enddef
Check()
END
v9.CheckScriptFailure(lines, 'E1013:')
lines =<< trim END
vim9script
class C
this.str: string
this.num: number
def newVals(this.str, this.num)
enddef
endclass
def Check()
try
var c = C.newVals('dogs', 'apes')
catch
assert_report($'Unexpected exception was caught: {v:exception}')
endtry
enddef
Check()
END
v9.CheckScriptFailure(lines, 'E1013:')
enddef
def Test_class_object_member_inits()
var lines =<< trim END
vim9script