comparison src/testdir/test_vim9_script.vim @ 21576:f4252efe370e v8.2.1338

patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type Commit: https://github.com/vim/vim/commit/8e4c8c853e3ffbd9258f89180692879ec6bce72b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 1 15:38:38 2020 +0200 patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type Problem: Vim9: assigning to script-local variable doesn't check type. Solution: Use the type. (issue https://github.com/vim/vim/issues/6591)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Aug 2020 15:45:06 +0200
parents b8b15e8cbf5f
children 7417cb54cb24
comparison
equal deleted inserted replaced
21575:69d8fbc507a1 21576:f4252efe370e
249 dd[""] = 6 249 dd[""] = 6
250 assert_equal({'': 6}, dd) 250 assert_equal({'': 6}, dd)
251 251
252 # type becomes dict<any> 252 # type becomes dict<any>
253 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} 253 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
254
255 # assignment to script-local dict
256 let lines =<< trim END
257 vim9script
258 let test: dict<any> = {}
259 def FillDict(): dict<any>
260 test['a'] = 43
261 return test
262 enddef
263 assert_equal(#{a: 43}, FillDict())
264 END
265 call CheckScriptSuccess(lines)
266
267 lines =<< trim END
268 vim9script
269 let test: dict<any>
270 def FillDict(): dict<any>
271 test['a'] = 43
272 return test
273 enddef
274 FillDict()
275 END
276 call CheckScriptFailure(lines, 'E1103:')
254 enddef 277 enddef
255 278
256 def Test_assignment_local() 279 def Test_assignment_local()
257 # Test in a separated file in order not to the current buffer/window/tab is 280 # Test in a separated file in order not to the current buffer/window/tab is
258 # changed. 281 # changed.