summaryrefslogtreecommitdiff
path: root/src/vim9script.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-15 18:17:28 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-15 18:17:28 +0200
commit227a69de1e0f9457a9fc9e098d999304faff55f8 (patch)
treecf8219eb91cb3474c8c01090dceda9d7c0602d57 /src/vim9script.c
parenta5d0077efbced85fcc63f203937b13efd55d036f (diff)
downloadvim-git-227a69de1e0f9457a9fc9e098d999304faff55f8.tar.gz
patch 8.2.0755: Vim9: No error when variable initializer is not a constantv8.2.0755
Problem: Vim9: No error when variable initializer is not a constant. Solution: Return FAIL when trying to get a variable value. Do not execute a script when an error is deteted in the first or second phase.
Diffstat (limited to 'src/vim9script.c')
-rw-r--r--src/vim9script.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/vim9script.c b/src/vim9script.c
index 4d7e8ee46..e213d61f1 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -37,6 +37,7 @@ ex_vim9script(exarg_T *eap)
garray_T func_ga;
int idx;
ufunc_T *ufunc;
+ int start_called_emsg = called_emsg;
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
{
@@ -66,7 +67,7 @@ ex_vim9script(exarg_T *eap)
// The types are recognized, so that they can be used when compiling a
// function.
gap = source_get_line_ga(eap->cookie);
- for (;;)
+ while (called_emsg == start_called_emsg)
{
char_u *line;
char_u *p;
@@ -132,22 +133,29 @@ ex_vim9script(exarg_T *eap)
}
else if (checkforcmd(&p, "finish", 4))
{
- // TODO: this should not happen below "if false".
- // Use "if cond | finish | endif as a workaround.
break;
}
}
// Compile the :def functions.
- for (idx = 0; idx < func_ga.ga_len; ++idx)
+ for (idx = 0; idx < func_ga.ga_len && called_emsg == start_called_emsg; ++idx)
{
ufunc = ((ufunc_T **)(func_ga.ga_data))[idx];
compile_def_function(ufunc, FALSE, NULL);
}
ga_clear(&func_ga);
- // Return to process the commands at the script level.
- source_use_line_ga(eap->cookie);
+ if (called_emsg == start_called_emsg)
+ {
+ // Return to process the commands at the script level.
+ source_use_line_ga(eap->cookie);
+ }
+ else
+ {
+ // If there was an error in the first or second phase then don't
+ // execute the script lines.
+ do_finish(eap, FALSE);
+ }
}
/*