Mercurial > vim
diff src/testdir/test_vim9_func.vim @ 21500:574517d682cf v8.2.1300
patch 8.2.1300: Vim9: optional argument type not parsed properly
Commit: https://github.com/vim/vim/commit/4fc224ca1cf2a8991c5ea17682a742c6ad5ad0f3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 26 17:56:25 2020 +0200
patch 8.2.1300: Vim9: optional argument type not parsed properly
Problem: Vim9: optional argument type not parsed properly.
Solution: Skip over the "?". (issue https://github.com/vim/vim/issues/6507)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Jul 2020 18:00:04 +0200 |
parents | 279b3415947f |
children | 179697662a5a |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -350,6 +350,19 @@ def Test_call_funcref() let Funcref: func(string) = function('UseNumber') END CheckScriptFailure(lines, 'E1013: type mismatch, expected func(string) but got func(number)') + + lines =<< trim END + vim9script + def EchoNr(nr = 34) + g:echo = nr + enddef + let Funcref: func(?number) = function('EchoNr') + Funcref() + assert_equal(34, g:echo) + Funcref(123) + assert_equal(123, g:echo) + END + CheckScriptSuccess(lines) enddef let SomeFunc = function('len')