patch 8.2.1934: Vim9: command modifiers in :def function not tested
Problem: Vim9: command modifiers in :def function not tested.
Solution: Add tests. Fix using modifier before filter command.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index bc1481d..4f1b62c 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2642,6 +2642,7 @@
type_T *type = ((type_T **)stack->ga_data)[
stack->ga_len - 2];
+ // add() can be compiled to instructions if we know the type
if (type->tt_type == VAR_LIST)
{
// inline "add(list, item)" so that the type can be checked
@@ -7173,10 +7174,6 @@
continue;
}
break;
-
- case ':':
- starts_with_colon = TRUE;
- break;
}
/*
@@ -7195,6 +7192,16 @@
generate_cmdmods(&cctx, &local_cmdmod);
undo_cmdmod(&local_cmdmod);
+ // Check if there was a colon after the last command modifier or before
+ // the current position.
+ for (p = ea.cmd; p >= line; --p)
+ {
+ if (*p == ':')
+ starts_with_colon = TRUE;
+ if (p < ea.cmd && !VIM_ISWHITE(*p))
+ break;
+ }
+
// Skip ":call" to get to the function name.
p = ea.cmd;
if (checkforcmd(&ea.cmd, "call", 3))