0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 8.2.1047: Vim9: script cannot use line continuation like :def function

Problem:    Vim9: script cannot use line continuation like in a :def function.
Solution:   Pass the getline function pointer to the eval() functions.  Use it
            for addition and multiplication operators.
This commit is contained in:
Bram Moolenaar
2020-06-24 18:37:35 +02:00
parent b7e2483655
commit 5409f5d8c9
15 changed files with 300 additions and 111 deletions

View File

@@ -788,12 +788,14 @@ get_literal_key(char_u **arg, typval_T *tv)
/*
* Allocate a variable for a Dictionary and fill it from "*arg".
* "literal" is TRUE for #{key: val}
* "flags" can have EVAL_EVALUATE and other EVAL_ flags.
* Return OK or FAIL. Returns NOTDONE for {expr}.
*/
int
eval_dict(char_u **arg, typval_T *rettv, int flags, int literal)
{
int evaluate = flags & EVAL_EVALUATE;
evalarg_T evalarg;
dict_T *d = NULL;
typval_T tvkey;
typval_T tv;
@@ -803,6 +805,9 @@ eval_dict(char_u **arg, typval_T *rettv, int flags, int literal)
char_u buf[NUMBUFLEN];
int vim9script = current_sctx.sc_version == SCRIPT_VERSION_VIM9;
CLEAR_FIELD(evalarg);
evalarg.eval_flags = flags;
/*
* First check if it's not a curly-braces thing: {expr}.
* Must do this without evaluating, otherwise a function may be called
@@ -812,7 +817,7 @@ eval_dict(char_u **arg, typval_T *rettv, int flags, int literal)
*/
if (!vim9script && *start != '}')
{
if (eval1(&start, &tv, 0) == FAIL) // recursive!
if (eval1(&start, &tv, NULL) == FAIL) // recursive!
return FAIL;
if (*start == '}')
return NOTDONE;
@@ -832,7 +837,7 @@ eval_dict(char_u **arg, typval_T *rettv, int flags, int literal)
{
if ((literal
? get_literal_key(arg, &tvkey)
: eval1(arg, &tvkey, flags)) == FAIL) // recursive!
: eval1(arg, &tvkey, &evalarg)) == FAIL) // recursive!
goto failret;
if (**arg != ':')
@@ -854,7 +859,7 @@ eval_dict(char_u **arg, typval_T *rettv, int flags, int literal)
}
*arg = skipwhite(*arg + 1);
if (eval1(arg, &tv, flags) == FAIL) // recursive!
if (eval1(arg, &tv, &evalarg) == FAIL) // recursive!
{
if (evaluate)
clear_tv(&tvkey);