mirror of
https://github.com/vim/vim.git
synced 2025-10-13 06:54:15 -04:00
patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Problem: Vim9: type wrong after getting dict item in lambda. Solution: Set the type to "any" after enforcing dict type. (closes #6491)
This commit is contained in:
@@ -1176,6 +1176,10 @@ def Test_expr7_lambda()
|
|||||||
let dl = [{'key': 0}, {'key': 22}]->filter({ _, v -> v['key'] })
|
let dl = [{'key': 0}, {'key': 22}]->filter({ _, v -> v['key'] })
|
||||||
assert_equal([{'key': 22}], dl)
|
assert_equal([{'key': 22}], dl)
|
||||||
|
|
||||||
|
dl = [{'key': 12}, {'foo': 34}]
|
||||||
|
assert_equal([{'key': 12}], filter(dl,
|
||||||
|
{_, v -> has_key(v, 'key') ? v['key'] == 12 : 0}))
|
||||||
|
|
||||||
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
|
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1256,
|
||||||
/**/
|
/**/
|
||||||
1255,
|
1255,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -3797,9 +3797,12 @@ compile_subscript(
|
|||||||
{
|
{
|
||||||
if ((*typep)->tt_type == VAR_DICT)
|
if ((*typep)->tt_type == VAR_DICT)
|
||||||
*typep = (*typep)->tt_member;
|
*typep = (*typep)->tt_member;
|
||||||
else if (need_type(*typep, &t_dict_any, -2, cctx, FALSE)
|
else
|
||||||
== FAIL)
|
{
|
||||||
return FAIL;
|
if (need_type(*typep, &t_dict_any, -2, cctx, FALSE) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
*typep = &t_any;
|
||||||
|
}
|
||||||
if (may_generate_2STRING(-1, cctx) == FAIL)
|
if (may_generate_2STRING(-1, cctx) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL)
|
if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL)
|
||||||
|
Reference in New Issue
Block a user