From f504e799a3f62e485b09fe8ab9470a991f43e7f5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 Apr 2024 07:39:10 +0800 Subject: [PATCH] vim-patch:9.1.0301: Vim9: heredoc start may be recognized in string (#28266) Problem: Vim9: heredoc start may be recognized in string. Solution: Don't skip to closing bracket for invalid list assignment. (zeertzjq) closes: vim/vim#14472 https://github.com/vim/vim/commit/1817ccdb107ceeaf5c48fe193da5146682c15ca6 --- src/nvim/eval/userfunc.c | 10 ++++------ test/old/testdir/test_let.vim | 15 +++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 72559fe9e0..d82d396d4d 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2578,13 +2578,11 @@ void ex_function(exarg_T *eap) if (checkforcmd(&arg, "let", 2)) { int var_count = 0; int semicolon = 0; - const char *argend = skip_var_list(arg, &var_count, &semicolon, true); - if (argend == NULL) { - // Invalid list assignment: skip to closing bracket. - argend = find_name_end(arg, NULL, NULL, FNE_INCL_BR); + arg = (char *)skip_var_list(arg, &var_count, &semicolon, true); + if (arg != NULL) { + arg = skipwhite(arg); } - arg = skipwhite(argend); - if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') { + if (arg != NULL && strncmp(arg, "=<<", 3) == 0) { p = skipwhite(arg + 3); while (true) { if (strncmp(p, "trim", 4) == 0) { diff --git a/test/old/testdir/test_let.vim b/test/old/testdir/test_let.vim index d93d33b199..655c177385 100644 --- a/test/old/testdir/test_let.vim +++ b/test/old/testdir/test_let.vim @@ -409,11 +409,17 @@ func Test_let_heredoc_fails() call assert_report('Caught exception: ' .. v:exception) endtry + try + let [] =<< trim TEXT + TEXT + call assert_report('No exception thrown') + catch /E475:/ + catch + call assert_report('Caught exception: ' .. v:exception) + endtry + try let [a b c] =<< trim TEXT - change - insert - append TEXT call assert_report('No exception thrown') catch /E475:/ @@ -423,9 +429,6 @@ func Test_let_heredoc_fails() try let [a; b; c] =<< trim TEXT - change - insert - append TEXT call assert_report('No exception thrown') catch /E452:/