]> granicus.if.org Git - vim/commitdiff
patch 8.2.4835: Vim9: some lines not covered by tests v8.2.4835
authorBram Moolenaar <Bram@vim.org>
Wed, 27 Apr 2022 21:15:40 +0000 (22:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 27 Apr 2022 21:15:40 +0000 (22:15 +0100)
Problem:    Vim9: some lines not covered by tests.
Solution:   Add a few more tests.  Fix disassemble output.

src/testdir/test_vim9_cmd.vim
src/testdir/test_vim9_disassemble.vim
src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index 49ca29b676aee8cce1efaaae65ffb60716e2a925..4cd78f6d11b3c74fd180e8146fe5ab237f67b1c6 100644 (file)
@@ -1691,6 +1691,9 @@ def Test_substitute_expr()
   endfor
   assert_equal('yes no abc', getline(1))
 
+  setline(1, 'from')
+  v9.CheckDefExecFailure(['s/from/\=g:notexist/'], 'E121: Undefined variable: g:notexist')
+
   bwipe!
 
   v9.CheckDefFailure(['s/from/\="x")/'], 'E488:')
index 1b2bd03ed764886e12726b8aa55e890cd7c83a70..086522ea32dda13a0880744a674b10d8d53f1e47 100644 (file)
@@ -899,6 +899,25 @@ def Test_disassemble_closure()
   unlet g:Get
 enddef
 
+def s:ClosureArg(arg: string)
+  var Ref = () => arg .. "x"
+enddef
+
+def Test_disassemble_closure_arg()
+  var res = execute('disass s:ClosureArg')
+  assert_match('<SNR>\d\+_ClosureArg\_s*' ..
+        'var Ref = () => arg .. "x"\_s*' ..
+        '\d FUNCREF <lambda>\d\+',
+        res)
+  var lres = execute('disass ' .. matchstr(res, '<lambda>\d\+'))
+  assert_match('<lambda>\d\+\_s*' ..
+        'return arg .. "x"\_s*' ..
+        '\d LOADOUTER level 1 arg\[-1]\_s*' ..
+        '\d PUSHS "x"\_s*' ..
+        '\d CONCAT size 2\_s*' ..
+        '\d RETURN',
+         lres)
+enddef
 
 def EchoArg(arg: string): string
   return arg
@@ -2664,6 +2683,22 @@ def Test_disassemble_dict_stack()
         res)
 enddef
 
+def s:RetLegacy(): string
+  legacy return "yes"
+enddef
+
+def Test_disassemble_return_legacy()
+  var res = execute('disass s:RetLegacy')
+  assert_match('<SNR>\d*_RetLegacy\_s*' ..
+          'legacy return "yes"\_s*' ..
+          '\d CMDMOD legacy\_s*' ..
+          '\d EVAL legacy "yes"\_s*' ..
+          '\d CHECKTYPE string stack\[-1]\_s*' ..
+          '\d CMDMOD_REV\_s*' ..
+          '\d RETURN',
+        res)
+enddef
+
 def s:EchoMessages()
   echohl ErrorMsg | echom v:exception | echohl NONE
 enddef
index 74159ca89a8c0f7c5cd52e2b5879814c099437ff..e108a2ca4600218211e276c17738c1ec5fd39612 100644 (file)
@@ -2376,6 +2376,14 @@ def Test_for_loop_unpack()
       endfor
   END
   v9.CheckDefExecFailure(lines, 'E1017:', 1)
+
+  lines =<< trim END
+      for [a, b] in g:listlist
+        echo a
+      endfor
+  END
+  g:listlist = [1, 2, 3]
+  v9.CheckDefExecFailure(lines, 'E1140:', 1)
 enddef
 
 def Test_for_loop_with_try_continue()
index c8dbb479415b39e66a37f20101031b373a1c2ba2..fa0303c086feaf993e5de3a3cc4d1b99326ea0e3 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4835,
 /**/
     4834,
 /**/
index 22813e1597741844059bb286c68f18d43fb922a3..7a65be3315bb9ab010f8040a70471284ed1e2d83 100644 (file)
@@ -5571,7 +5571,7 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
                break;
            case ISN_LOADOUTER:
                {
-                   if (iptr->isn_arg.number < 0)
+                   if (iptr->isn_arg.outer.outer_idx < 0)
                        smsg("%s%4d LOADOUTER level %d arg[%d]", pfx, current,
                                iptr->isn_arg.outer.outer_depth,
                                iptr->isn_arg.outer.outer_idx