Vim9: Unexpected error message when using multiple lines with extend()

8 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Jan 10, 2022, 11:26:45 AM1/10/22
to vim_dev
Hi,

When I source the following Vim9 script:

--------------------------------------------------------------------------------------
vim9script

def Test()
var a: dict<any> = {b: {}}
a.b->extend({f1: 1,
f2: 2})
enddef
v:errmsg = ''
Test()
echo v:errmsg
--------------------------------------------------------------------------------------

I get the "E116: Invalid arguments for function extend({f1: 1," error.
If I pass the arguments to extend() in a single line, then it works
without this error. Is this expected?

Interestingly, this error doesn't abort the function and the error
message is not displayed automatically. It is only set in the
v:errmsg variable.

- Yegappan

Bram Moolenaar

unread,
Jan 10, 2022, 1:40:36 PM1/10/22
to vim...@googlegroups.com, Yegappan Lakshmanan
This happens when compiling the function, if you replace "Test()" with
"defcompile" you also get the error.

It happens when skipping over the expression, which happens without
evaluating, but that isn't checked at this point.

--
A cow comes flying over the battlements, lowing aggressively. The cow
lands on GALAHAD'S PAGE, squashing him completely.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages