Problem: Vim9: crash when using lambda without return type in dict.
Solution: Without a return type use t_unknown. (closes #7587)
assert_equal(g:test_hash_dict, {one: 1, two: 2})
assert_equal({['a a']: 1, ['b/c']: 2}, {'a a': 1, "b/c": 2})
+
+ var d = {a: () => 3, b: () => 7}
+ assert_equal(3, d.a())
+ assert_equal(7, d.b())
END
CheckDefAndScriptSuccess(lines)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2252,
/**/
2251,
/**/
if (cctx->ctx_skip != SKIP_YES)
{
stack_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
- if (check_return_type && cctx->ctx_ufunc->uf_ret_type == NULL)
+ if (check_return_type && (cctx->ctx_ufunc->uf_ret_type == NULL
+ || cctx->ctx_ufunc->uf_ret_type == &t_unknown))
{
cctx->ctx_ufunc->uf_ret_type = stack_type;
}
}
else if (expected->tt_type == VAR_FUNC)
{
- if (expected->tt_member != &t_unknown)
+ // If the return type is unknown it can be anything, including
+ // nothing, thus there is no point in checking.
+ if (expected->tt_member != &t_unknown
+ && actual->tt_member != &t_unknown)
ret = check_type(expected->tt_member, actual->tt_member,
FALSE, 0);
if (ret == OK && expected->tt_argcount != -1