mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.2.4840: heredoc expression evaluated even when skipping
Problem: Heredoc expression evaluated even when skipping. Solution: Don't evaluate when "skip" is set. (closes #10306)
This commit is contained in:
@@ -835,7 +835,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (evalstr)
|
||||
if (evalstr && !eap->skip)
|
||||
{
|
||||
str = eval_all_expr_in_str(str);
|
||||
if (str == NULL)
|
||||
|
@@ -509,20 +509,24 @@ func Test_let_heredoc_eval()
|
||||
let c = "abc`=str`d"
|
||||
END
|
||||
call assert_equal(['let a = 15', 'let b = 6 + 6', '', 'let c = "abcd"'], code)
|
||||
|
||||
let $TESTVAR = "Hello"
|
||||
let code =<< eval trim END
|
||||
let s = "`=$TESTVAR`"
|
||||
END
|
||||
call assert_equal(['let s = "Hello"'], code)
|
||||
|
||||
let code =<< eval END
|
||||
let s = "`=$TESTVAR`"
|
||||
END
|
||||
call assert_equal([' let s = "Hello"'], code)
|
||||
|
||||
let a = 10
|
||||
let data =<< eval END
|
||||
`=a`
|
||||
END
|
||||
call assert_equal(['10'], data)
|
||||
|
||||
let x = 'X'
|
||||
let code =<< eval trim END
|
||||
let a = `abc`
|
||||
@@ -530,12 +534,14 @@ END
|
||||
let c = `
|
||||
END
|
||||
call assert_equal(['let a = `abc`', 'let b = X', 'let c = `'], code)
|
||||
|
||||
let code = 'xxx'
|
||||
let code =<< eval trim END
|
||||
let n = `=5 +
|
||||
6`
|
||||
END
|
||||
call assert_equal('xxx', code)
|
||||
|
||||
let code =<< eval trim END
|
||||
let n = `=min([1, 2]` + `=max([3, 4])`
|
||||
END
|
||||
@@ -562,6 +568,13 @@ END
|
||||
LINES
|
||||
call v9.CheckScriptFailure(lines, 'E15:')
|
||||
|
||||
" skipped heredoc
|
||||
if 0
|
||||
let msg =<< trim eval END
|
||||
n is: `=n`
|
||||
END
|
||||
endif
|
||||
|
||||
" Test for sourcing a script containing a heredoc with invalid expression.
|
||||
" Variable assignment should fail, if expression evaluation fails
|
||||
new
|
||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4840,
|
||||
/**/
|
||||
4839,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user