Patch 8.2.2792
Problem:    Vim9: :disas shows instructions for default args but no text.
Solution:   Show the expression test above the default argument instructions.
            (closes #8129)
Files:      src/vim9execute.c, src/testdir/test_vim9_disassemble.vim


*** ../vim-8.2.2791/src/vim9execute.c   2021-04-19 20:49:58.156857538 +0200
--- src/vim9execute.c   2021-04-20 22:09:58.056178728 +0200
***************
*** 4338,4343 ****
--- 4338,4344 ----
      int               line_idx = 0;
      int               prev_current = 0;
      int               current;
+     int               def_arg_idx = 0;
  
      for (current = 0; current < instr_count; ++current)
      {
***************
*** 4345,4350 ****
--- 4346,4352 ----
        char        *line;
  
        if (ufunc != NULL)
+       {
            while (line_idx < iptr->isn_lnum
                                          && line_idx < ufunc->uf_lines.ga_len)
            {
***************
*** 4357,4362 ****
--- 4359,4381 ----
                if (line != NULL)
                    msg(line);
            }
+           if (iptr->isn_type == ISN_JUMP_IF_ARG_SET)
+           {
+               int     first_def_arg = ufunc->uf_args.ga_len
+                                                  - ufunc->uf_def_args.ga_len;
+ 
+               if (def_arg_idx > 0)
+                   msg_puts("\n\n");
+               msg_start();
+               msg_puts("  ");
+               msg_puts(((char **)(ufunc->uf_args.ga_data))[
+                                                first_def_arg + def_arg_idx]);
+               msg_puts(" = ");
+               msg_puts(((char 
**)(ufunc->uf_def_args.ga_data))[def_arg_idx++]);
+               msg_clr_eos();
+               msg_end();
+           }
+       }
  
        switch (iptr->isn_type)
        {
*** ../vim-8.2.2791/src/testdir/test_vim9_disassemble.vim       2021-04-19 
20:49:58.156857538 +0200
--- src/testdir/test_vim9_disassemble.vim       2021-04-20 22:13:56.007463131 
+0200
***************
*** 724,743 ****
  enddef
  
  
! def FuncWithDefault(arg: string = 'default', nr = 77): string
    return arg .. nr
  enddef
  
  def Test_disassemble_call_default()
    var res = execute('disass FuncWithDefault')
    assert_match('FuncWithDefault\_s*' ..
          '\d JUMP_IF_ARG_SET arg\[-2\] -> 3\_s*' ..
          '\d PUSHS "default"\_s*' ..
          '\d STORE arg\[-2]\_s*' ..
          '3 JUMP_IF_ARG_SET arg\[-1\] -> 6\_s*' ..
          '\d PUSHNR 77\_s*' ..
          '\d STORE arg\[-1]\_s*' ..
!         'return arg .. nr\_s*' ..
          '6 LOAD arg\[-2]\_s*' ..
          '\d LOAD arg\[-1]\_s*' ..
          '\d 2STRING stack\[-1]\_s*' ..
--- 724,745 ----
  enddef
  
  
! def FuncWithDefault(l: number, arg: string = "default", nr = 77): string
    return arg .. nr
  enddef
  
  def Test_disassemble_call_default()
    var res = execute('disass FuncWithDefault')
    assert_match('FuncWithDefault\_s*' ..
+         '  arg = "default"\_s*' ..
          '\d JUMP_IF_ARG_SET arg\[-2\] -> 3\_s*' ..
          '\d PUSHS "default"\_s*' ..
          '\d STORE arg\[-2]\_s*' ..
+         '  nr = 77\_s*' ..
          '3 JUMP_IF_ARG_SET arg\[-1\] -> 6\_s*' ..
          '\d PUSHNR 77\_s*' ..
          '\d STORE arg\[-1]\_s*' ..
!         '  return arg .. nr\_s*' ..
          '6 LOAD arg\[-2]\_s*' ..
          '\d LOAD arg\[-1]\_s*' ..
          '\d 2STRING stack\[-1]\_s*' ..
*** ../vim-8.2.2791/src/version.c       2021-04-20 21:49:32.231668519 +0200
--- src/version.c       2021-04-20 22:00:24.949873829 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2792,
  /**/

-- 
Don't drink and drive.  You might hit a bump and spill your beer.

 /// 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/202104202017.13KKH3f5929872%40masaka.moolenaar.net.

Raspunde prin e-mail lui