Problem: Vim9: no error for using script var name for argument.
Solution: Check for this error. (closes #7868)
/* 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);
END
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 5)
+ 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)
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)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2540,
/**/
2539,
/**/
* "cctx" is NULL at the script level.
* Returns OK or FAIL.
*/
- static int
+ int
script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx)
{
int is_vim9_script;