changeset 30795:b8cda1e1c985 v9.0.0732

patch 9.0.0732: no check for white space before and after "=<<" Commit: https://github.com/vim/vim/commit/d987642626f84fe2f0b32a1ca5ede31b436ce677 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 12 12:58:54 2022 +0100 patch 9.0.0732: no check for white space before and after "=<<" Problem: No check for white space before and after "=<<". (Doug Kearns) Solution: Check for white space in Vim9 script. (closes https://github.com/vim/vim/issues/11351)
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Oct 2022 14:00:04 +0200
parents d784ec592fbc
children 454cefb34cfa
files src/evalvars.c src/testdir/test_vim9_assign.vim src/version.c
diffstat 3 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1066,11 +1066,18 @@ ex_let(exarg_T *eap)
     }
     else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<')
     {
-	list_T	*l;
+	list_T	*l = NULL;
 	long	cur_lnum = SOURCING_LNUM;
 
-	// HERE document
-	l = heredoc_get(eap, expr + 3, FALSE, FALSE);
+	// :let text =<< [trim] [eval] END
+	// :var text =<< [trim] [eval] END
+	if (vim9script && !eap->skip && (!VIM_ISWHITE(expr[-1])
+						 || !IS_WHITE_OR_NUL(expr[3])))
+	    semsg(_(e_white_space_required_before_and_after_str_at_str),
+								  "=<<", expr);
+	else
+	    l = heredoc_get(eap, expr + 3, FALSE, FALSE);
+
 	if (l != NULL)
 	{
 	    rettv_list_set(&rettv, l);
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1904,6 +1904,25 @@ def Test_heredoc()
       STOP
   END
   v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<string>', 1)
+
+  lines =<< trim END
+      var lines=<< STOP
+        xxx
+      STOP
+  END
+  v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''=<<'' at "=<< STOP"', 1)
+  lines =<< trim END
+      var lines =<<STOP
+        xxx
+      STOP
+  END
+  v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''=<<'' at "=<<STOP"', 1)
+  lines =<< trim END
+      var lines=<<STOP
+        xxx
+      STOP
+  END
+  v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''=<<'' at "=<<STOP"', 1)
 enddef
 
 def Test_var_func_call()
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    732,
+/**/
     731,
 /**/
     730,