mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-patch:8.1.1722: error when scriptversion is 2 a making a dictionary access
Problem: Error when scriptversion is 2 a making a dictionary access.
Solution: Parse the subscript even when not evaluating the sub-expression.
(closes vim/vim#4704)
61343f0c44
:scriptversion is N/A.
This commit is contained in:
@@ -1456,21 +1456,18 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
|||||||
/*
|
/*
|
||||||
* Assign the typevalue "tv" to the variable or variables at "arg_start".
|
* Assign the typevalue "tv" to the variable or variables at "arg_start".
|
||||||
* Handles both "var" with any type and "[var, var; var]" with a list type.
|
* Handles both "var" with any type and "[var, var; var]" with a list type.
|
||||||
* When "nextchars" is not NULL it points to a string with characters that
|
* When "op" is not NULL it points to a string with characters that
|
||||||
* must appear after the variable(s). Use "+", "-" or "." for add, subtract
|
* must appear after the variable(s). Use "+", "-" or "." for add, subtract
|
||||||
* or concatenate.
|
* or concatenate.
|
||||||
* Returns OK or FAIL;
|
* Returns OK or FAIL;
|
||||||
*/
|
*/
|
||||||
static int
|
static int ex_let_vars(char_u *arg_start,
|
||||||
ex_let_vars(
|
typval_T *tv,
|
||||||
char_u *arg_start,
|
int copy, // copy values from "tv", don't move
|
||||||
typval_T *tv,
|
int semicolon, // from skip_var_list()
|
||||||
int copy, // copy values from "tv", don't move
|
int var_count, // from skip_var_list()
|
||||||
int semicolon, // from skip_var_list()
|
int is_const, // lock variables for :const
|
||||||
int var_count, // from skip_var_list()
|
char_u *op)
|
||||||
int is_const, // lock variables for :const
|
|
||||||
char_u *nextchars
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
char_u *arg = arg_start;
|
char_u *arg = arg_start;
|
||||||
typval_T ltv;
|
typval_T ltv;
|
||||||
@@ -1479,7 +1476,7 @@ ex_let_vars(
|
|||||||
/*
|
/*
|
||||||
* ":let var = expr" or ":for var in list"
|
* ":let var = expr" or ":for var in list"
|
||||||
*/
|
*/
|
||||||
if (ex_let_one(arg, tv, copy, is_const, nextchars, nextchars) == NULL) {
|
if (ex_let_one(arg, tv, copy, is_const, op, op) == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
@@ -1510,7 +1507,7 @@ ex_let_vars(
|
|||||||
while (*arg != ']') {
|
while (*arg != ']') {
|
||||||
arg = skipwhite(arg + 1);
|
arg = skipwhite(arg + 1);
|
||||||
arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, is_const,
|
arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, is_const,
|
||||||
(const char_u *)",;]", nextchars);
|
(const char_u *)",;]", op);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -1532,8 +1529,8 @@ ex_let_vars(
|
|||||||
ltv.vval.v_list = rest_list;
|
ltv.vval.v_list = rest_list;
|
||||||
tv_list_ref(rest_list);
|
tv_list_ref(rest_list);
|
||||||
|
|
||||||
arg = ex_let_one(skipwhite(arg + 1), <v, false, is_const,
|
arg = ex_let_one(skipwhite(arg + 1), <v, false, is_const, (char_u *)"]",
|
||||||
(char_u *)"]", nextchars);
|
op);
|
||||||
tv_clear(<v);
|
tv_clear(<v);
|
||||||
if (arg == NULL) {
|
if (arg == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -8675,6 +8672,7 @@ handle_subscript(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "." is ".name" lookup when we found a dict.
|
||||||
while (ret == OK
|
while (ret == OK
|
||||||
&& (((**arg == '[' || (**arg == '.' && rettv->v_type == VAR_DICT)
|
&& (((**arg == '[' || (**arg == '.' && rettv->v_type == VAR_DICT)
|
||||||
|| (**arg == '(' && (!evaluate || tv_is_func(*rettv))))
|
|| (**arg == '(' && (!evaluate || tv_is_func(*rettv))))
|
||||||
|
Reference in New Issue
Block a user