1
0
forked from aniani/vim

patch 8.2.0733: Vim9: assigning to dict or list argument does not work

Problem:    Vim9: assigning to dict or list argument does not work.
Solution:   Recognize an argument as assignment target.
This commit is contained in:
Bram Moolenaar
2020-05-10 22:53:56 +02:00
parent f163bd5e41
commit cb2bdb1c6d
3 changed files with 52 additions and 6 deletions

View File

@@ -193,6 +193,26 @@ def Test_using_var_as_arg()
call delete('Xdef')
enddef
def DictArg(arg: dict<string>)
arg['key'] = 'value'
enddef
def ListArg(arg: list<string>)
arg[0] = 'value'
enddef
def Test_assign_to_argument()
" works for dict and list
let d: dict<string> = {}
DictArg(d)
assert_equal('value', d['key'])
let l: list<string> = []
ListArg(l)
assert_equal('value', l[0])
call CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef'], 'E1090:')
enddef
def Test_call_func_defined_later()
call assert_equal('one', g:DefinedLater('one'))
call assert_fails('call NotDefined("one")', 'E117:')