Patch 8.2.1372
Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around ? and :.
Files:      src/eval.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1371/src/eval.c  2020-08-05 12:32:34.519963712 +0200
--- src/eval.c  2020-08-05 12:42:50.829677325 +0200
***************
*** 2072,2078 ****
   *    expr2 ? expr1 : expr1
   *
   * "arg" must point to the first non-white of the expression.
!  * "arg" is advanced to the next non-white after the recognized expression.
   *
   * Note: "rettv.v_lock" is not set.
   *
--- 2072,2078 ----
   *    expr2 ? expr1 : expr1
   *
   * "arg" must point to the first non-white of the expression.
!  * "arg" is advanced to just after the recognized expression.
   *
   * Note: "rettv.v_lock" is not set.
   *
***************
*** 2111,2117 ****
--- 2111,2125 ----
        if (getnext)
            *arg = eval_next_line(evalarg_used);
        else
+       {
+           if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+           {
+               error_white_both(p, 1);
+               clear_tv(rettv);
+               return FAIL;
+           }
            *arg = p;
+       }
  
        result = FALSE;
        if (evaluate)
***************
*** 2128,2133 ****
--- 2136,2147 ----
        /*
         * Get the second variable.  Recursive!
         */
+       if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
+       {
+           error_white_both(p, 1);
+           clear_tv(rettv);
+           return FAIL;
+       }
        *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
        evalarg_used->eval_flags = result ? orig_flags
                                                 : orig_flags & ~EVAL_EVALUATE;
***************
*** 2148,2158 ****
--- 2162,2186 ----
        if (getnext)
            *arg = eval_next_line(evalarg_used);
        else
+       {
+           if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+           {
+               error_white_both(p, 1);
+               clear_tv(rettv);
+               return FAIL;
+           }
            *arg = p;
+       }
  
        /*
         * Get the third variable.  Recursive!
         */
+       if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
+       {
+           error_white_both(p, 1);
+           clear_tv(rettv);
+           return FAIL;
+       }
        *arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
        evalarg_used->eval_flags = !result ? orig_flags
                                                 : orig_flags & ~EVAL_EVALUATE;
***************
*** 2179,2185 ****
   *    expr2 || expr2 || expr2     logical OR
   *
   * "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.
   */
--- 2207,2213 ----
   *    expr2 || expr2 || expr2     logical OR
   *
   * "arg" must point to the first non-white of the expression.
!  * "arg" is advanced to just after the recognized expression.
   *
   * Return OK or FAIL.
   */
***************
*** 2310,2316 ****
   *    expr3 && expr3 && expr3     logical AND
   *
   * "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.
   */
--- 2338,2344 ----
   *    expr3 && expr3 && expr3     logical AND
   *
   * "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.1371/src/testdir/test_vim9_expr.vim      2020-08-05 
12:32:34.523963696 +0200
--- src/testdir/test_vim9_expr.vim      2020-08-05 12:39:17.918444490 +0200
***************
*** 60,66 ****
  enddef
  
  def Test_expr1_vimscript()
!   # only checks line continuation
    let lines =<< trim END
        vim9script
        let var = 1
--- 60,66 ----
  enddef
  
  def Test_expr1_vimscript()
!   # check line continuation
    let lines =<< trim END
        vim9script
        let var = 1
***************
*** 87,92 ****
--- 87,119 ----
        assert_equal('no', var)
    END
    CheckScriptSuccess(lines)
+ 
+   # check white space
+   lines =<< trim END
+       vim9script
+       let var = v:true?1:2
+   END
+   CheckScriptFailure(lines, 'E1004:')
+   lines =<< trim END
+       vim9script
+       let var = v:true? 1 : 2
+   END
+   CheckScriptFailure(lines, 'E1004:')
+   lines =<< trim END
+       vim9script
+       let var = v:true ?1 : 2
+   END
+   CheckScriptFailure(lines, 'E1004:')
+   lines =<< trim END
+       vim9script
+       let var = v:true ? 1: 2
+   END
+   CheckScriptFailure(lines, 'E1004:')
+   lines =<< trim END
+       vim9script
+       let var = v:true ? 1 :2
+   END
+   CheckScriptFailure(lines, 'E1004:')
  enddef
  
  func Test_expr1_fails()
*** ../vim-8.2.1371/src/version.c       2020-08-05 12:32:34.523963696 +0200
--- src/version.c       2020-08-05 12:44:10.997392344 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1372,
  /**/

-- 
Statistics say that you can have a baby per month on average:
Just get nine women pregnant.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202008051045.075Aj30n3264199%40masaka.moolenaar.net.

Raspunde prin e-mail lui