patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Problem: Vim9: no way to explicitly ignore an argument.
Solution: Use the underscore as the name for an ignored argument.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index e5e3068..b005ff2 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4416,6 +4416,12 @@
// "name" or "name()"
p = to_name_end(*arg, TRUE);
+ if (p - *arg == (size_t)1 && **arg == '_')
+ {
+ emsg(_(e_cannot_use_underscore_here));
+ return FAIL;
+ }
+
if (*p == '(')
{
r = compile_call(arg, p - *arg, cctx, ppconst, 0);
@@ -6378,6 +6384,11 @@
semsg(_(e_cannot_assign_to_constant), lhs.lhs_name);
goto theend;
}
+ if (is_decl && lhs.lhs_name[0] == '_' && lhs.lhs_name[1] == NUL)
+ {
+ emsg(_(e_cannot_use_underscore_here));
+ goto theend;
+ }
if (!heredoc)
{