diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-28 16:51:41 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-28 16:51:41 +0100 |
commit | 05c7f5d3d03440da6f69604f8c06c4e3d90d2a26 (patch) | |
tree | 2d91131156c98374b6a9b092307331f6fcceac11 /src | |
parent | 0a748d91846a4c3422975acc0af78c806623c191 (diff) |
patch 8.2.4840: heredoc expression evaluated even when skippingv8.2.4840
Problem: Heredoc expression evaluated even when skipping.
Solution: Don't evaluate when "skip" is set. (closes #10306)
Diffstat (limited to 'src')
-rw-r--r-- | src/evalvars.c | 2 | ||||
-rw-r--r-- | src/testdir/test_let.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index ffa7e93f71..21a0e5b79f 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -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) diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim index 2606fa276b..32f91f65bc 100644 --- a/src/testdir/test_let.vim +++ b/src/testdir/test_let.vim @@ -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 diff --git a/src/version.c b/src/version.c index c3b6326669..0570614fc8 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4840, +/**/ 4839, /**/ 4838, |