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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user