Patch 8.2.4946
Problem:    Vim9: some code not covered by tests.
Solution:   Add a few more test cases.  Remove dead code.
Files:      src/vim9expr.c, src/testdir/test_vim9_expr.vim,
            src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.4945/src/vim9expr.c      2022-05-12 11:05:36.180621684 +0100
--- src/vim9expr.c      2022-05-12 21:40:10.368725295 +0100
***************
*** 1122,1128 ****
      r = get_lambda_tv(arg, rettv, types_optional, evalarg);
      current_sctx.sc_version = save_sc_version;
      if (r != OK)
!       return r;
  
      // "rettv" will now be a partial referencing the function.
      ufunc = rettv->vval.v_partial->pt_func;
--- 1122,1128 ----
      r = get_lambda_tv(arg, rettv, types_optional, evalarg);
      current_sctx.sc_version = save_sc_version;
      if (r != OK)
!       return r;  // currently unreachable
  
      // "rettv" will now be a partial referencing the function.
      ufunc = rettv->vval.v_partial->pt_func;
***************
*** 1682,1693 ****
                                            -1, 0, cctx, FALSE, FALSE) == FAIL)
                return FAIL;
  
-           while (p > start && (p[-1] == '-' || p[-1] == '+'))
-           {
-               --p;
-               if (*p == '-')
-                   negate = !negate;
-           }
            // only '-' has an effect, for '+' we only check the type
            if (negate)
            {
--- 1682,1687 ----
*** ../vim-8.2.4945/src/testdir/test_vim9_expr.vim      2022-05-12 
11:05:36.184621676 +0100
--- src/testdir/test_vim9_expr.vim      2022-05-12 22:01:29.955737773 +0100
***************
*** 2151,2156 ****
--- 2151,2159 ----
    vv = $'other {val}'
    assert_equal('other val', vv)
  
+   v9.CheckDefAndScriptFailure(['var x = $"foo'], 'E114:', 1)
+   v9.CheckDefAndScriptFailure(['var x = $"foo{xxx}"'], ['E1001: Variable not 
found: xxx', 'E121: Undefined variable: xxx'], 1)
+ 
    var x = 'x'
    var vl = 'foo xxx bar xxx baz'
                ->split($'x{x}x')
***************
*** 2818,2823 ****
--- 2821,2827 ----
    g:key = 'x'
    v9.CheckDefExecAndScriptFailure(["var x = {[g:key]: 'text', [g:key]: 
'text'}"], 'E721:', 1)
    unlet g:key
+   v9.CheckDefExecAndScriptFailure(["var x = {[notexists]: 'text'}"], 
['E1001:', 'E121: Undefined variable: notexists'], 1)
    v9.CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 
'E488:'], 1)
    v9.CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
  
***************
*** 3370,3375 ****
--- 3374,3382 ----
        assert_equal('onetwo', s)
    END
    v9.CheckDefAndScriptSuccess(lines)
+ 
+   v9.CheckDefAndScriptFailure(['echo ('], ['E1097: Line incomplete', 'E15: 
Invalid expression: "("'])
+   v9.CheckDefAndScriptFailure(['echo (123]'], "E110: Missing ')'", 1)
  enddef
  
  def Test_expr8_negate_add()
***************
*** 3480,3485 ****
--- 3487,3493 ----
         "var x = substitute ('x', 'x', 'x', 'x')"
         ], ['E1001:', 'E121:'], 1)
    v9.CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], 
['E1123:', 'E116:'], 1)
+   v9.CheckDefAndScriptFailure(["echo match(['foo'] , 'foo')"], 'E1068:', 1)
  enddef
  
  def g:ExistingGlobal(): string
***************
*** 4000,4005 ****
--- 4008,4023 ----
    v9.CheckDefAndScriptSuccess(lines)
  enddef
  
+ def Test_expr8_funcref_subscript()
+   var lines =<< trim END
+       var l = function('len')("abc")
+       assert_equal(3, l)
+   END
+   v9.CheckDefAndScriptSuccess(lines)
+ 
+   v9.CheckDefAndScriptFailure(["var l = function('len')(xxx)"], ['E1001: 
Variable not found: xxx', 'E121: Undefined variable: xxx'], 1)
+ enddef
+ 
  def Test_expr8_subscript_linebreak()
    var lines =<< trim END
        var range = range(
*** ../vim-8.2.4945/src/testdir/test_vim9_builtin.vim   2022-05-12 
11:05:36.184621676 +0100
--- src/testdir/test_vim9_builtin.vim   2022-05-12 21:06:40.353455840 +0100
***************
*** 78,83 ****
--- 78,84 ----
  
  def Test_add()
    v9.CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type 
mismatch, expected list<any> but got dict<unknown>', 'E1226: List or Blob 
required for argument 1'])
+   v9.CheckDefAndScriptFailure(['add([])'], 'E119:')
    v9.CheckDefExecFailure([
          'var ln: list<number> = [1]',
          'add(ln, "a")'],
*** ../vim-8.2.4945/src/version.c       2022-05-12 20:35:32.331574770 +0100
--- src/version.c       2022-05-12 20:59:28.393786307 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4946,
  /**/

-- 
Wizards had always known that the act of observation changed the thing that
was observed, and sometimes forgot that it also changed the observer too.
                        Terry Pratchett  -  Interesting times

 /// 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/20220512210339.B4FB81C1EE1%40moolenaar.net.

Raspunde prin e-mail lui