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

patch 8.2.1223: Vim9: invalid type error for function default value

Problem:    Vim9: invalid type error for function default value.
Solution:   Use right argument index. (closes #6458)
This commit is contained in:
Bram Moolenaar
2020-07-15 19:48:20 +02:00
parent 657a826c07
commit e30f64b4b5
3 changed files with 11 additions and 1 deletions

View File

@@ -104,11 +104,19 @@ def MyDefaultArgs(name = 'string'): string
return name
enddef
def MyDefaultSecond(name: string, second: bool = true): string
return second ? name : 'none'
enddef
def Test_call_default_args()
assert_equal('string', MyDefaultArgs())
assert_equal('one', MyDefaultArgs('one'))
assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
assert_equal('test', MyDefaultSecond('test'))
assert_equal('test', MyDefaultSecond('test', true))
assert_equal('none', MyDefaultSecond('test', false))
CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:')
CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: argument 1: type mismatch, expected number but got string')
enddef