Patch 8.2.2942
Problem:    Vim9: internal error when calling function with too few arguments
Solution:   Check for argument count to be too few. (closes #8325)
Files:      src/errors.h, src/vim9execute.c, src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.2941/src/errors.h        2021-06-02 16:47:49.675250216 +0200
--- src/errors.h        2021-06-05 17:26:15.775890723 +0200
***************
*** 419,421 ****
--- 419,425 ----
        INIT(= N_("E1188: Cannot open a terminal from the command line 
window"));
  EXTERN char e_cannot_use_legacy_with_command_str[]
        INIT(= N_("E1189: Cannot use :legacy with this command: %s"));
+ EXTERN char e_one_argument_too_few[]
+       INIT(= N_("E1190: One argument too few"));
+ EXTERN char e_nr_arguments_too_few[]
+       INIT(= N_("E1190: %d arguments too few"));
*** ../vim-8.2.2941/src/vim9execute.c   2021-06-05 17:10:46.538051161 +0200
--- src/vim9execute.c   2021-06-05 17:31:17.515151487 +0200
***************
*** 4234,4239 ****
--- 4234,4247 ----
            semsg(_(e_nr_arguments_too_many), idx);
        goto failed_early;
      }
+     else if (idx < 0)
+     {
+       if (idx == -1)
+           emsg(_(e_one_argument_too_few));
+       else
+           semsg(_(e_nr_arguments_too_few), -idx);
+       goto failed_early;
+     }
  
      // Put arguments on the stack, but no more than what the function expects.
      // A lambda can be called with more arguments than it uses.
*** ../vim-8.2.2941/src/testdir/test_vim9_builtin.vim   2021-05-26 
21:10:07.285101484 +0200
--- src/testdir/test_vim9_builtin.vim   2021-06-05 18:14:24.010128603 +0200
***************
*** 810,815 ****
--- 810,824 ----
        assert_equal(['0:a', '1:b', '2:c'], l)
    END
    CheckDefAndScriptSuccess(lines)
+ 
+   lines =<< trim END
+       range(3)->map((a, b, c) => a + b + c)
+   END
+   CheckDefExecAndScriptFailure(lines, 'E1190: One argument too few')
+   lines =<< trim END
+       range(3)->map((a, b, c, d) => a + b + c + d)
+   END
+   CheckDefExecAndScriptFailure(lines, 'E1190: 2 arguments too few')
  enddef
  
  def Test_map_item_type()
*** ../vim-8.2.2941/src/version.c       2021-06-05 17:10:46.542051152 +0200
--- src/version.c       2021-06-05 17:30:14.551306412 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2942,
  /**/

-- 
"I love deadlines.  I especially like the whooshing sound they
make as they go flying by."
                         -- Douglas Adams

 /// 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/202106051615.155GFap9078957%40masaka.moolenaar.net.

Raspunde prin e-mail lui