comparison src/testdir/test_vim9_func.vim @ 21504:e87a97868bbc v8.2.1302

patch 8.2.1302: Vim9: varargs arg after optional arg does not work Commit: https://github.com/vim/vim/commit/01865ade85d2508639e24aaca5948b09fb284a82 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 26 18:33:09 2020 +0200 patch 8.2.1302: Vim9: varargs arg after optional arg does not work Problem: Vim9: varargs arg after optional arg does not work Solution: Check for the "..." first. (issue https://github.com/vim/vim/issues/6507)
author Bram Moolenaar <Bram@vim.org>
date Sun, 26 Jul 2020 18:45:06 +0200
parents 179697662a5a
children 6c67c86a202a
comparison
equal deleted inserted replaced
21503:e10b92dd259f 21504:e87a97868bbc
374 assert_equal([], g:echo) 374 assert_equal([], g:echo)
375 Funcref(1, 2, 3) 375 Funcref(1, 2, 3)
376 assert_equal([1, 2, 3], g:echo) 376 assert_equal([1, 2, 3], g:echo)
377 END 377 END
378 CheckScriptSuccess(lines) 378 CheckScriptSuccess(lines)
379
380 lines =<< trim END
381 vim9script
382 def OptAndVar(nr: number, opt = 12, ...l: list<number>): number
383 g:optarg = opt
384 g:listarg = l
385 return nr
386 enddef
387 let Funcref: func(number, ?number, ...list<number>): number = function('OptAndVar')
388 assert_equal(10, Funcref(10))
389 assert_equal(12, g:optarg)
390 assert_equal([], g:listarg)
391
392 assert_equal(11, Funcref(11, 22))
393 assert_equal(22, g:optarg)
394 assert_equal([], g:listarg)
395
396 assert_equal(17, Funcref(17, 18, 1, 2, 3))
397 assert_equal(18, g:optarg)
398 assert_equal([1, 2, 3], g:listarg)
399 END
400 CheckScriptSuccess(lines)
379 enddef 401 enddef
380 402
381 let SomeFunc = function('len') 403 let SomeFunc = function('len')
382 let NotAFunc = 'text' 404 let NotAFunc = 'text'
383 405