Commit: patch 9.2.1015: Vim9: v:errmsg is set while looking ahead at a command

4 views
Skip to first unread message

Christian Brabandt

unread,
Aug 27, 2026, 5:30:19 PM (4 days ago) Aug 27
to vim...@googlegroups.com
patch 9.2.1015: Vim9: v:errmsg is set while looking ahead at a command

Commit: https://github.com/vim/vim/commit/5ab969f719bb09555e90e8dff8c94fc37bcbf2ae
Author: Hirohito Higashi <h.eas...@gmail.com>
Date: Thu Aug 27 21:14:34 2026 +0000

patch 9.2.1015: Vim9: v:errmsg is set while looking ahead at a command

Problem: In Vim9 script a line starting with a dict member is looked
ahead at, to tell an assignment from an expression. Where the
expression runs on into the next line the lookahead cannot
follow it, and what it makes of that reaches "v:errmsg" and
whatever is being redirected, though nothing is wrong and the
function compiles.
Solution: Turn error messages off around the lookahead instead of
silencing them (Hirohito Higashi).

closes: #21168

Co-Authored-By: Claude Opus 5 (1M context) <nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index f5771cb61..c7343d290 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3848,7 +3848,7 @@ find_ex_command(
// name[idx].member = val
// etc.
eap->cmdidx = CMD_eval;
- ++emsg_silent;
+ ++emsg_off;
if (skip_expr(&after, NULL) == OK)
{
after = skipwhite(after);
@@ -3857,7 +3857,7 @@ find_ex_command(
&& after[2] == '='))
eap->cmdidx = CMD_var;
}
- --emsg_silent;
+ --emsg_off;
return eap->cmd;
}

diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 8eaa2a875..68623273e 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -2251,4 +2251,21 @@ def Test_delfunction_dict_funcref()
v9.CheckScriptSuccess(lines)
enddef

+" Looking ahead at a line that starts with a dict member, to tell an
+" assignment from an expression, must not leave an error behind.
+def Test_no_error_from_looking_ahead()
+ var lines =<< trim END
+ vim9script
+ var d = {Fn: (m: string) => 0}
+ def F(b: bool)
+ d.Fn(b ? 'one'
+ : 'two')
+ enddef
+ v:errmsg = ''
+ defcompile
+ assert_equal('', v:errmsg)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_generics.vim b/src/testdir/test_vim9_generics.vim
index 9aadd99cf..c86c1e7c7 100644
--- a/src/testdir/test_vim9_generics.vim
+++ b/src/testdir/test_vim9_generics.vim
@@ -1211,7 +1211,7 @@ def Test_generic_obj_method()
var a = A.new()
a.Fn<>()
END
- v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function '<>()'"])
+ v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function 'Fn'"])

lines =<< trim END
vim9script
@@ -1295,7 +1295,7 @@ def Test_generic_obj_method_call_from_another_method()
enddef
defcompile
END
- v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function '<>()'"])
+ v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function 'Fn'"])

lines =<< trim END
vim9script
@@ -1476,7 +1476,7 @@ def Test_generic_class_method()
endclass
A.Fn<>()
END
- v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function '<>()'"])
+ v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function 'Fn'"])

lines =<< trim END
vim9script
@@ -1554,7 +1554,7 @@ def Test_generic_class_method_call_from_another_method()
enddef
defcompile
END
- v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function '<>()'"])
+ v9.CheckSourceFailureList(lines, ["E1555: Empty type list specified for generic function 'Fn'"])

lines =<< trim END
vim9script
diff --git a/src/version.c b/src/version.c
index b8ad10924..fb880c7c1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1015,
/**/
1014,
/**/
Reply all
Reply to author
Forward
0 new messages