Patch 8.2.2252

3 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 31, 2020, 7:32:02 AM12/31/20
to vim...@googlegroups.com

Patch 8.2.2252
Problem: Vim9: crash when using lambda without return type in dict.
Solution: Without a return type use t_unknown. (closes #7587)
Files: src/vim9type.c, src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.2251/src/vim9type.c 2020-12-26 20:09:11.282465257 +0100
--- src/vim9type.c 2020-12-31 13:13:41.001169456 +0100
***************
*** 480,486 ****
}
else if (expected->tt_type == VAR_FUNC)
{
! if (expected->tt_member != &t_unknown)
ret = check_type(expected->tt_member, actual->tt_member,
FALSE, 0);
if (ret == OK && expected->tt_argcount != -1
--- 480,489 ----
}
else if (expected->tt_type == VAR_FUNC)
{
! // 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
*** ../vim-8.2.2251/src/vim9compile.c 2020-12-30 20:39:17.450007607 +0100
--- src/vim9compile.c 2020-12-31 13:29:59.541798974 +0100
***************
*** 4837,4843 ****
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)
{
cctx->ctx_ufunc->uf_ret_type = stack_type;
}
--- 4837,4844 ----
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
! || cctx->ctx_ufunc->uf_ret_type == &t_unknown))
{
cctx->ctx_ufunc->uf_ret_type = stack_type;
}
*** ../vim-8.2.2251/src/testdir/test_vim9_expr.vim 2020-12-30 20:39:17.454007601 +0100
--- src/testdir/test_vim9_expr.vim 2020-12-31 13:08:29.366103323 +0100
***************
*** 2077,2082 ****
--- 2077,2086 ----
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)

*** ../vim-8.2.2251/src/version.c 2020-12-30 21:16:27.727686851 +0100
--- src/version.c 2020-12-31 13:07:35.894249182 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2252,
/**/

--
ERROR 047: Keyboard not found. Press RETURN to continue.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages