mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.2139: Vim9: unreachable code in assignment
Problem: Vim9: unreachable code in assignment. Solution: Don't check "new_local" when "has_index" is set. Add test for wrong type of list index.
This commit is contained in:
parent
b5b9480ee9
commit
acbae18df5
@ -326,6 +326,18 @@ def Test_assign_index()
|
|||||||
END
|
END
|
||||||
CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict<unknown>', 3)
|
CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict<unknown>', 3)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var lines: list<string>
|
||||||
|
lines['a'] = 'asdf'
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E39:', 2)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
var lines: string
|
||||||
|
lines[9] = 'asdf'
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E1141:', 2)
|
||||||
|
|
||||||
# list of dict
|
# list of dict
|
||||||
var ld: list<dict<number>>
|
var ld: list<dict<number>>
|
||||||
ld[0] = {}
|
ld[0] = {}
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2139,
|
||||||
/**/
|
/**/
|
||||||
2138,
|
2138,
|
||||||
/**/
|
/**/
|
||||||
|
@ -5856,8 +5856,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
// Compile the "idx" in "var[idx]" or "key" in "var.key".
|
// Compile the "idx" in "var[idx]" or "key" in "var.key".
|
||||||
if (new_local)
|
|
||||||
--cctx->ctx_locals.ga_len;
|
|
||||||
p = var_start + varlen;
|
p = var_start + varlen;
|
||||||
if (*p == '[')
|
if (*p == '[')
|
||||||
{
|
{
|
||||||
@ -5877,8 +5875,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
|
|
||||||
r = generate_PUSHS(cctx, key);
|
r = generate_PUSHS(cctx, key);
|
||||||
}
|
}
|
||||||
if (new_local)
|
|
||||||
++cctx->ctx_locals.ga_len;
|
|
||||||
if (r == FAIL)
|
if (r == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user