Patch 8.2.2540
Problem: Vim9: no error for using script var name for argument.
Solution: Check for this error. (closes #7868)
Files: src/userfunc.c, src/vim9compile.c, src/proto/vim9compile.pro,
src/testdir/test_vim9_func.vim
*** ../vim-8.2.2539/src/userfunc.c 2021-02-20 20:26:10.118866290 +0100
--- src/userfunc.c 2021-02-21 22:16:10.870537859 +0100
***************
*** 80,85 ****
--- 80,93 ----
semsg(_("E125: Illegal argument: %s"), arg);
return arg;
}
+
+ // Vim9 script: cannot use script var name for argument.
+ if (argtypes != NULL && script_var_exists(arg, p - arg, FALSE, NULL) ==
OK)
+ {
+ semsg(_(e_variable_already_declared_in_script), arg);
+ return arg;
+ }
+
if (newargs != NULL && ga_grow(newargs, 1) == FAIL)
return arg;
if (newargs != NULL)
*** ../vim-8.2.2539/src/vim9compile.c 2021-02-21 21:32:38.301201176 +0100
--- src/vim9compile.c 2021-02-21 22:16:19.566502626 +0100
***************
*** 337,343 ****
* "cctx" is NULL at the script level.
* Returns OK or FAIL.
*/
! static int
script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx)
{
int is_vim9_script;
--- 337,343 ----
* "cctx" is NULL at the script level.
* Returns OK or FAIL.
*/
! int
script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx)
{
int is_vim9_script;
*** ../vim-8.2.2539/src/proto/vim9compile.pro 2021-01-24 12:53:30.780247041
+0100
--- src/proto/vim9compile.pro 2021-02-21 22:16:49.466381514 +0100
***************
*** 1,4 ****
--- 1,5 ----
/* vim9compile.c */
+ int script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx);
int check_defined(char_u *p, size_t len, cctx_T *cctx);
int check_compare_types(exprtype_T type, typval_T *tv1, typval_T *tv2);
int use_typecheck(type_T *actual, type_T *expected);
*** ../vim-8.2.2539/src/testdir/test_vim9_func.vim 2021-02-14
13:17:16.992007963 +0100
--- src/testdir/test_vim9_func.vim 2021-02-21 22:17:22.142249166 +0100
***************
*** 591,596 ****
--- 591,605 ----
lines =<< trim END
vim9script
+ var name = 'piet'
+ def FuncOne(name: string)
+ echo nr
+ enddef
+ END
+ CheckScriptFailure(lines, 'E1054:')
+
+ lines =<< trim END
+ vim9script
def FuncOne(nr: number)
echo nr
enddef
*** ../vim-8.2.2539/src/version.c 2021-02-21 21:32:38.305201161 +0100
--- src/version.c 2021-02-21 22:19:36.121706430 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2540,
/**/
--
ARTHUR: Charge!
[They all charge with swords drawn towards the RABBIT. A tremendous twenty
second fight with Peckinpahish shots and borrowing heavily also on the
Kung Fu and karate-type films ensues, in which some four KNIGHTS are
comprehensively killed.]
ARTHUR: Run away! Run away!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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/202102212126.11LLQP3G3293295%40masaka.moolenaar.net.