summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-02 16:47:53 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-02 16:47:53 +0200
commitc3cb1c92a335be818971acd89f631e82aa30ad3f (patch)
tree876f7b5a57548ef6655187a4a3d4108d6dc13865 /src/vim9compile.c
parent0f37e3561db95b0ef0b636588bbd30297e377384 (diff)
downloadvim-git-c3cb1c92a335be818971acd89f631e82aa30ad3f.tar.gz
patch 8.2.2926: Vim9: no good error for using :legacy in a :def functionv8.2.2926
Problem: Vim9: no good error for using :legacy in a :def function. Solution: Give an explicit error where :legacy is not working. (closes #8309)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 2ea487de7..5152b61a5 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -9222,6 +9222,27 @@ compile_def_function(
{
char_u *start = ea.cmd;
+ switch (ea.cmdidx)
+ {
+ case CMD_if:
+ case CMD_elseif:
+ case CMD_else:
+ case CMD_endif:
+ case CMD_for:
+ case CMD_endfor:
+ case CMD_continue:
+ case CMD_break:
+ case CMD_while:
+ case CMD_endwhile:
+ case CMD_try:
+ case CMD_catch:
+ case CMD_finally:
+ case CMD_endtry:
+ semsg(_(e_cannot_use_legacy_with_command_str), ea.cmd);
+ goto erret;
+ default: break;
+ }
+
// ":legacy return expr" needs to be handled differently.
if (checkforcmd(&start, "return", 4))
ea.cmdidx = CMD_return;