To: vim_dev@googlegroups.com Subject: Patch 8.2.1368 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1368 Problem: Vim9: no error for missing white space around operator. Solution: Check for white space around <, !=, etc. Files: src/eval.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1367/src/eval.c 2020-08-05 11:36:48.495643306 +0200 --- src/eval.c 2020-08-05 11:50:23.874006732 +0200 *************** *** 2422,2428 **** * var1 isnot var2 * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to the next non-white after the recognized expression. * * Return OK or FAIL. */ --- 2422,2428 ---- * var1 isnot var2 * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to just after the recognized expression. * * Return OK or FAIL. */ *************** *** 2452,2460 **** --- 2452,2468 ---- typval_T var2; int ic; int vim9script = in_vim9script(); + int evaluate = evalarg == NULL + ? 0 : (evalarg->eval_flags & EVAL_EVALUATE); if (getnext) *arg = eval_next_line(evalarg); + else if (evaluate && vim9script && !VIM_ISWHITE(**arg)) + { + error_white_both(p, len); + clear_tv(rettv); + return FAIL; + } if (vim9script && type_is && (p[len] == '?' || p[len] == '#')) { *************** *** 2482,2494 **** /* * Get the second variable. */ *arg = skipwhite_and_linebreak(p + len, evalarg); if (eval5(arg, &var2, evalarg) == FAIL) { clear_tv(rettv); return FAIL; } ! if (evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE)) { int ret; --- 2490,2508 ---- /* * Get the second variable. */ + if (evaluate && vim9script && !IS_WHITE_OR_NUL(p[len])) + { + error_white_both(p, 1); + clear_tv(rettv); + return FAIL; + } *arg = skipwhite_and_linebreak(p + len, evalarg); if (eval5(arg, &var2, evalarg) == FAIL) { clear_tv(rettv); return FAIL; } ! if (evaluate) { int ret; *************** *** 2552,2558 **** * .. string concatenation * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to the next non-white after the recognized expression. * * Return OK or FAIL. */ --- 2566,2572 ---- * .. string concatenation * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to just after the recognized expression. * * Return OK or FAIL. */ *************** *** 2754,2760 **** * % number modulo * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to the next non-white after the recognized expression. * * Return OK or FAIL. */ --- 2768,2774 ---- * % number modulo * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to just after the recognized expression. * * Return OK or FAIL. */ *************** *** 2956,2962 **** * trailing ->name() method call * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to the next non-white after the recognized expression. * * Return OK or FAIL. */ --- 2970,2976 ---- * trailing ->name() method call * * "arg" must point to the first non-white of the expression. ! * "arg" is advanced to just after the recognized expression. * * Return OK or FAIL. */ *** ../vim-8.2.1367/src/testdir/test_vim9_expr.vim 2020-08-05 11:36:48.495643306 +0200 --- src/testdir/test_vim9_expr.vim 2020-08-05 11:44:07.830819916 +0200 *************** *** 726,731 **** --- 726,763 ---- set noignorecase END CheckScriptSuccess(lines) + + # check missing white space + lines =<< trim END + vim9script + echo 2>3 + END + CheckScriptFailure(lines, 'E1004:') + lines =<< trim END + vim9script + echo 2 >3 + END + CheckScriptFailure(lines, 'E1004:') + lines =<< trim END + vim9script + echo 2> 3 + END + CheckScriptFailure(lines, 'E1004:') + lines =<< trim END + vim9script + echo 2!=3 + END + CheckScriptFailure(lines, 'E1004:') + lines =<< trim END + vim9script + echo 2 !=3 + END + CheckScriptFailure(lines, 'E1004:') + lines =<< trim END + vim9script + echo 2!= 3 + END + CheckScriptFailure(lines, 'E1004:') enddef func Test_expr4_fails() *** ../vim-8.2.1367/src/version.c 2020-08-05 11:36:48.495643306 +0200 --- src/version.c 2020-08-05 11:51:13.349889559 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1368, /**/ -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///