To: vim_dev@googlegroups.com Subject: Patch 8.2.3111 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3111 Problem: Vim9: confusing error with extra whitespace before colon. Solution: Check for colon after white space. (closes #8513) Files: src/eval.c, src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.3110/src/eval.c 2021-06-27 22:03:28.637707737 +0200 --- src/eval.c 2021-07-05 21:35:14.639368162 +0200 *************** *** 1660,1665 **** --- 1660,1666 ---- evalarg_T *evalarg) { forinfo_T *fi; + char_u *var_list_end; char_u *expr; typval_T tv; list_T *l; *************** *** 1671,1685 **** if (fi == NULL) return NULL; ! expr = skip_var_list(arg, TRUE, &fi->fi_varcount, &fi->fi_semicolon, FALSE); ! if (expr == NULL) return fi; ! expr = skipwhite_and_linebreak(expr, evalarg); if (expr[0] != 'i' || expr[1] != 'n' || !(expr[2] == NUL || VIM_ISWHITE(expr[2]))) { ! emsg(_(e_missing_in)); return fi; } --- 1672,1690 ---- if (fi == NULL) return NULL; ! var_list_end = skip_var_list(arg, TRUE, &fi->fi_varcount, ! &fi->fi_semicolon, FALSE); ! if (var_list_end == NULL) return fi; ! expr = skipwhite_and_linebreak(var_list_end, evalarg); if (expr[0] != 'i' || expr[1] != 'n' || !(expr[2] == NUL || VIM_ISWHITE(expr[2]))) { ! if (in_vim9script() && *expr == ':' && expr != var_list_end) ! semsg(_(e_no_white_space_allowed_before_colon_str), expr); ! else ! emsg(_(e_missing_in)); return fi; } *** ../vim-8.2.3110/src/vim9compile.c 2021-07-04 22:48:08.261371720 +0200 --- src/vim9compile.c 2021-07-05 21:39:09.858919317 +0200 *************** *** 7775,7781 **** return NULL; if (STRNCMP(p, "in", 2) != 0 || !IS_WHITE_OR_NUL(p[2])) { ! emsg(_(e_missing_in)); return NULL; } wp = p + 2; --- 7775,7784 ---- return NULL; if (STRNCMP(p, "in", 2) != 0 || !IS_WHITE_OR_NUL(p[2])) { ! if (*p == ':' && wp != p) ! semsg(_(e_no_white_space_allowed_before_colon_str), p); ! else ! emsg(_(e_missing_in)); return NULL; } wp = p + 2; *** ../vim-8.2.3110/src/testdir/test_vim9_script.vim 2021-07-04 14:47:27.455118487 +0200 --- src/testdir/test_vim9_script.vim 2021-07-05 21:37:34.855104149 +0200 *************** *** 2566,2571 **** --- 2566,2578 ---- endfor END CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got string', 1) + + lines =<< trim END + for n : number in [1, 2] + echo n + endfor + END + CheckDefAndScriptFailure(lines, 'E1059:', 1) enddef def Test_for_loop_script_var() *** ../vim-8.2.3110/src/version.c 2021-07-05 20:14:54.400221570 +0200 --- src/version.c 2021-07-05 21:34:26.935457918 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3111, /**/ -- From "know your smileys": 8-O "Omigod!!" (done "rm -rf *" ?) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///