Mercurial > vim
diff src/userfunc.c @ 23996:c192411b27e8 v8.2.2540
patch 8.2.2540: Vim9: no error for using script var name for argument
Commit: https://github.com/vim/vim/commit/b4893b84507570f24af32597716ffb67fb0ef24e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 21 22:20:24 2021 +0100
patch 8.2.2540: Vim9: no error for using script var name for argument
Problem: Vim9: no error for using script var name for argument.
Solution: Check for this error. (closes https://github.com/vim/vim/issues/7868)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Feb 2021 22:30:05 +0100 |
parents | 686af23ec132 |
children | 90fbe1a3b23c |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -80,6 +80,14 @@ one_function_arg( 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)