Patch 8.2.3016
Problem:    Confusing error when expression is followed by comma.
Solution:   Give a different error for trailing text. (closes #8395)
Files:      src/eval.c, src/testdir/test_let.vim,
            src/testdir/test_eval_stuff.vim, src/testdir/test_vim9_expr.vim,
            src/testdir/test_vim9_script.vim, src/testdir/test_viminfo.vim,
            src/testdir/test_vimscript.vim


*** ../vim-8.2.3015/src/eval.c  2021-06-13 14:01:22.756396984 +0200
--- src/eval.c  2021-06-17 21:51:54.747370574 +0200
***************
*** 2218,2229 ****
      int               did_emsg_before = did_emsg;
      int               called_emsg_before = called_emsg;
      int               flags = evalarg == NULL ? 0 : evalarg->eval_flags;
  
      p = skipwhite(arg);
      ret = eval1(&p, rettv, evalarg);
      p = skipwhite(p);
  
!     if (ret == FAIL || !ends_excmd2(arg, p))
      {
        if (ret != FAIL)
            clear_tv(rettv);
--- 2218,2232 ----
      int               did_emsg_before = did_emsg;
      int               called_emsg_before = called_emsg;
      int               flags = evalarg == NULL ? 0 : evalarg->eval_flags;
+     int               end_error = FALSE;
  
      p = skipwhite(arg);
      ret = eval1(&p, rettv, evalarg);
      p = skipwhite(p);
  
!     if (ret != FAIL)
!       end_error = !ends_excmd2(arg, p);
!     if (ret == FAIL || end_error)
      {
        if (ret != FAIL)
            clear_tv(rettv);
***************
*** 2238,2244 ****
                && called_emsg == called_emsg_before
                && (flags & EVAL_CONSTANT) == 0
                && (!in_vim9script() || !vim9_bad_comment(p)))
!           semsg(_(e_invexpr2), arg);
  
        // Some of the expression may not have been consumed.  Do not check for
        // a next command to avoid more errors, unless "|" is following, which
--- 2241,2252 ----
                && called_emsg == called_emsg_before
                && (flags & EVAL_CONSTANT) == 0
                && (!in_vim9script() || !vim9_bad_comment(p)))
!       {
!           if (end_error)
!               semsg(_(e_trailing_arg), p);
!           else
!               semsg(_(e_invexpr2), arg);
!       }
  
        // Some of the expression may not have been consumed.  Do not check for
        // a next command to avoid more errors, unless "|" is following, which
*** ../vim-8.2.3015/src/testdir/test_let.vim    2021-04-05 20:59:38.507328567 
+0200
--- src/testdir/test_let.vim    2021-06-17 21:51:24.091452761 +0200
***************
*** 314,319 ****
--- 314,320 ----
      let ch = test_null_channel()
      call assert_fails('let ch += 1', 'E734:')
    endif
+   call assert_fails('let name = "a" .. "b",', 'E488: Trailing characters: ,')
  
    " This test works only when the language is English
    if v:lang == "C" || v:lang =~ '^[Ee]n'
*** ../vim-8.2.3015/src/testdir/test_eval_stuff.vim     2021-06-06 
14:14:35.352774336 +0200
--- src/testdir/test_eval_stuff.vim     2021-06-17 21:58:07.538369403 +0200
***************
*** 165,171 ****
  
    call assert_fails('echo a . b', 'E15:')
    call assert_fails('let a .= b', 'E985:')
!   call assert_fails('let vers = 1.2.3', 'E15:')
  
    if has('float')
      let f = .5
--- 165,171 ----
  
    call assert_fails('echo a . b', 'E15:')
    call assert_fails('let a .= b', 'E985:')
!   call assert_fails('let vers = 1.2.3', 'E488:')
  
    if has('float')
      let f = .5
*** ../vim-8.2.3015/src/testdir/test_vim9_expr.vim      2021-06-15 
22:13:23.829621578 +0200
--- src/testdir/test_vim9_expr.vim      2021-06-17 22:01:30.545823229 +0200
***************
*** 2340,2346 ****
    CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2)
    CheckDefAndScriptFailure2(["var x = {['a']: xxx}"], 'E1001:', 'E121:', 1)
    CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1)
!   CheckDefExecAndScriptFailure2(["var x = g:anint.member"], 'E715:', 'E15:', 
1)
    CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
  
    CheckDefExecAndScriptFailure(['var x: dict<number> = {a: 234, b: "1"}'], 
'E1012:', 1)
--- 2340,2346 ----
    CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2)
    CheckDefAndScriptFailure2(["var x = {['a']: xxx}"], 'E1001:', 'E121:', 1)
    CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1)
!   CheckDefExecAndScriptFailure2(["var x = g:anint.member"], 'E715:', 'E488:', 
1)
    CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
  
    CheckDefExecAndScriptFailure(['var x: dict<number> = {a: 234, b: "1"}'], 
'E1012:', 1)
***************
*** 3052,3058 ****
  
    call CheckDefAndScriptFailure2(["var x = [notfound]"], "E1001:", 'E121:', 1)
  
!   call CheckDefAndScriptFailure2(["var X = () => 123)"], "E488:", 'E15:', 1)
    call CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1)
  
    call CheckDefAndScriptFailure(["var x = &notexist"], 'E113:', 1)
--- 3052,3058 ----
  
    call CheckDefAndScriptFailure2(["var x = [notfound]"], "E1001:", 'E121:', 1)
  
!   call CheckDefAndScriptFailure(["var X = () => 123)"], 'E488:', 1)
    call CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1)
  
    call CheckDefAndScriptFailure(["var x = &notexist"], 'E113:', 1)
***************
*** 3070,3076 ****
    call CheckDefExecAndScriptFailure(["var x = +g:alist"], 'E745:', 1)
    call CheckDefExecAndScriptFailure(["var x = +g:adict"], 'E728:', 1)
  
!   call CheckDefAndScriptFailure2(["var x = ''", "var y = x.memb"], 'E715:', 
'E15:', 2)
  
    call CheckDefAndScriptFailure2(["'yes'->", "Echo()"], 'E488: Trailing 
characters: ->', 'E260: Missing name after ->', 1)
  
--- 3070,3076 ----
    call CheckDefExecAndScriptFailure(["var x = +g:alist"], 'E745:', 1)
    call CheckDefExecAndScriptFailure(["var x = +g:adict"], 'E728:', 1)
  
!   call CheckDefAndScriptFailure2(["var x = ''", "var y = x.memb"], 'E715:', 
'E488:', 2)
  
    call CheckDefAndScriptFailure2(["'yes'->", "Echo()"], 'E488: Trailing 
characters: ->', 'E260: Missing name after ->', 1)
  
***************
*** 3354,3361 ****
  endfunc
  
  func Test_expr_fails()
!   call CheckDefAndScriptFailure2(["var x = '1'is2"], 'E488:', 'E15:', 1)
!   call CheckDefAndScriptFailure2(["var x = '1'isnot2"], 'E488:', 'E15:', 1)
  
    call CheckDefAndScriptFailure2(["CallMe ('yes')"], 'E476:', 'E492:', 1)
  
--- 3354,3361 ----
  endfunc
  
  func Test_expr_fails()
!   call CheckDefAndScriptFailure(["var x = '1'is2"], 'E488:', 1)
!   call CheckDefAndScriptFailure(["var x = '1'isnot2"], 'E488:', 1)
  
    call CheckDefAndScriptFailure2(["CallMe ('yes')"], 'E476:', 'E492:', 1)
  
*** ../vim-8.2.3015/src/testdir/test_vim9_script.vim    2021-06-15 
20:06:30.646818721 +0200
--- src/testdir/test_vim9_script.vim    2021-06-17 22:02:35.105649450 +0200
***************
*** 3212,3218 ****
        'if 1# comment3',
        '  echo "yes"',
        'endif',
!       ], 'E15:')
  
    CheckScriptFailure([
        'vim9script',
--- 3212,3218 ----
        'if 1# comment3',
        '  echo "yes"',
        'endif',
!       ], 'E488:')
  
    CheckScriptFailure([
        'vim9script',
***************
*** 3221,3227 ****
        'elseif 2#comment',
        '  echo "no"',
        'endif',
!       ], 'E15:')
  
    CheckScriptSuccess([
        'vim9script',
--- 3221,3227 ----
        'elseif 2#comment',
        '  echo "no"',
        'endif',
!       ], 'E488:')
  
    CheckScriptSuccess([
        'vim9script',
***************
*** 3231,3237 ****
    CheckScriptFailure([
        'vim9script',
        'var v = 1# comment6',
!       ], 'E15:')
  
    CheckScriptSuccess([
        'vim9script',
--- 3231,3237 ----
    CheckScriptFailure([
        'vim9script',
        'var v = 1# comment6',
!       ], 'E488:')
  
    CheckScriptSuccess([
        'vim9script',
*** ../vim-8.2.3015/src/testdir/test_viminfo.vim        2021-06-16 
15:53:13.072696639 +0200
--- src/testdir/test_viminfo.vim        2021-06-17 22:03:18.789531865 +0200
***************
*** 128,134 ****
          \ "!GLOB_BLOB_4\tBLO\t0z12 ab",
          \ "!GLOB_LIST_1\tLIS\t1 2",
          \ "!GLOB_DICT_1\tDIC\t1 2"], 'Xviminfo')
!   call assert_fails('rv! Xviminfo', 'E15:')
    call assert_equal('123', g:GLOB_BLOB_1)
    call assert_equal(1, type(g:GLOB_BLOB_1))
    call assert_equal('012', g:GLOB_BLOB_2)
--- 128,134 ----
          \ "!GLOB_BLOB_4\tBLO\t0z12 ab",
          \ "!GLOB_LIST_1\tLIS\t1 2",
          \ "!GLOB_DICT_1\tDIC\t1 2"], 'Xviminfo')
!   call assert_fails('rv! Xviminfo', 'E488:')
    call assert_equal('123', g:GLOB_BLOB_1)
    call assert_equal(1, type(g:GLOB_BLOB_1))
    call assert_equal('012', g:GLOB_BLOB_2)
*** ../vim-8.2.3015/src/testdir/test_vimscript.vim      2021-06-10 
18:43:21.743644898 +0200
--- src/testdir/test_vimscript.vim      2021-06-17 22:06:23.241035225 +0200
***************
*** 5570,5576 ****
      call T(19, '{(1} + CONT(19)',     'E110', "Missing ')'")
      call T(20, '("abc"[1) + CONT(20)',        'E111', "Missing ']'")
      call T(21, '(1 +) + CONT(21)',    'E15',  "Invalid expression")
!     call T(22, '1 2 + CONT(22)',      'E15',  "Invalid expression")
      call T(23, '(1 ? 2) + CONT(23)',  'E109', "Missing ':' after '?'")
      call T(24, '("abc) + CONT(24)',   'E114', "Missing quote")
      call T(25, "('abc) + CONT(25)",   'E115', "Missing quote")
--- 5570,5576 ----
      call T(19, '{(1} + CONT(19)',     'E110', "Missing ')'")
      call T(20, '("abc"[1) + CONT(20)',        'E111', "Missing ']'")
      call T(21, '(1 +) + CONT(21)',    'E15',  "Invalid expression")
!     call T(22, '1 2 + CONT(22)',      'E488', "Trailing characters: 2 +")
      call T(23, '(1 ? 2) + CONT(23)',  'E109', "Missing ':' after '?'")
      call T(24, '("abc) + CONT(24)',   'E114', "Missing quote")
      call T(25, "('abc) + CONT(25)",   'E115', "Missing quote")
*** ../vim-8.2.3015/src/version.c       2021-06-17 21:03:04.038634999 +0200
--- src/version.c       2021-06-17 21:48:22.823938076 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     3016,
  /**/

-- 
Everybody wants to go to heaven, but nobody wants to die.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/202106172009.15HK90Tq1734930%40masaka.moolenaar.net.

Raspunde prin e-mail lui