0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase

Problem:    Vim9: expressions are evaluated in the discovery phase.
Solution:   Bail out if an expression is not a constant.  Require a type for
            declared constants.
This commit is contained in:
Bram Moolenaar
2020-05-14 22:41:15 +02:00
parent e06a28f5e3
commit 32e351179e
12 changed files with 214 additions and 131 deletions

View File

@@ -2869,14 +2869,14 @@ to_name_const_end(char_u *arg)
{
// Can be "[1, 2, 3]->Func()".
if (get_list_tv(&p, &rettv, FALSE, FALSE) == FAIL)
if (get_list_tv(&p, &rettv, 0, FALSE) == FAIL)
p = arg;
}
else if (p == arg && *arg == '#' && arg[1] == '{')
{
// Can be "#{a: 1}->Func()".
++p;
if (eval_dict(&p, &rettv, FALSE, TRUE) == FAIL)
if (eval_dict(&p, &rettv, 0, TRUE) == FAIL)
p = arg;
}
else if (p == arg && *arg == '{')
@@ -2886,7 +2886,7 @@ to_name_const_end(char_u *arg)
// Can be "{x -> ret}()".
// Can be "{'a': 1}->Func()".
if (ret == NOTDONE)
ret = eval_dict(&p, &rettv, FALSE, FALSE);
ret = eval_dict(&p, &rettv, 0, FALSE);
if (ret != OK)
p = arg;
}