mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
vim-patch:9.1.0287: Vim9: comment may be treated as heredoc start (#28257)
Problem: Vim9: comment may be treated as heredoc start.
(Ernie Rael)
Solution: Use skip_var_list() instead of find_name_end().
(zeertzjq)
fixes: vim/vim#14444
closes: vim/vim#14446
9a91d2b72c
This commit is contained in:
@@ -2576,10 +2576,14 @@ void ex_function(exarg_T *eap)
|
|||||||
// and ":let [a, b] =<< [trim] EOF"
|
// and ":let [a, b] =<< [trim] EOF"
|
||||||
arg = p;
|
arg = p;
|
||||||
if (checkforcmd(&arg, "let", 2)) {
|
if (checkforcmd(&arg, "let", 2)) {
|
||||||
while (vim_strchr("$@&", *arg) != NULL) {
|
int var_count = 0;
|
||||||
arg++;
|
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 = skipwhite(find_name_end(arg, NULL, NULL, FNE_INCL_BR));
|
arg = skipwhite(argend);
|
||||||
if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') {
|
if (arg[0] == '=' && arg[1] == '<' && arg[2] == '<') {
|
||||||
p = skipwhite(arg + 3);
|
p = skipwhite(arg + 3);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@@ -397,6 +397,42 @@ func Test_let_heredoc_fails()
|
|||||||
call assert_report('Caught exception: ' .. v:exception)
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
try
|
||||||
|
let @- =<< trim TEXT
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
TEXT
|
||||||
|
call assert_report('No exception thrown')
|
||||||
|
catch /E730:/
|
||||||
|
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:/
|
||||||
|
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 /E452:/
|
||||||
|
catch
|
||||||
|
call assert_report('Caught exception: ' .. v:exception)
|
||||||
|
endtry
|
||||||
|
|
||||||
let text =<< trim END
|
let text =<< trim END
|
||||||
func WrongSyntax()
|
func WrongSyntax()
|
||||||
let v =<< that there
|
let v =<< that there
|
||||||
@@ -569,6 +605,22 @@ append
|
|||||||
END
|
END
|
||||||
call assert_equal(['change', 'insert', 'append'], [a, b, c])
|
call assert_equal(['change', 'insert', 'append'], [a, b, c])
|
||||||
|
|
||||||
|
" unpack assignment with semicolon
|
||||||
|
let [a; b] =<< END
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
END
|
||||||
|
call assert_equal(['change', ['insert', 'append']], [a, b])
|
||||||
|
|
||||||
|
" unpack assignment with registers
|
||||||
|
let [@/, @", @-] =<< END
|
||||||
|
change
|
||||||
|
insert
|
||||||
|
append
|
||||||
|
END
|
||||||
|
call assert_equal(['change', 'insert', 'append'], [@/, @", @-])
|
||||||
|
|
||||||
" curly braces name and list slice assignment
|
" curly braces name and list slice assignment
|
||||||
let foo_3_bar = ['', '', '']
|
let foo_3_bar = ['', '', '']
|
||||||
let foo_{1 + 2}_bar[ : ] =<< END
|
let foo_{1 + 2}_bar[ : ] =<< END
|
||||||
|
Reference in New Issue
Block a user