Patch 9.0.0695

4 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 8, 2022, 9:40:21 AM10/8/22
to vim...@googlegroups.com

Patch 9.0.0695
Problem: Failing check for dictionary type for const any.
Solution: Check for any type properly. (closes #11310)
Files: src/vim9instr.c, src/testdir/test_vim9_script.vim


*** ../vim-9.0.0694/src/vim9instr.c 2022-10-07 15:09:24.608804815 +0100
--- src/vim9instr.c 2022-10-08 14:11:12.365504357 +0100
***************
*** 1831,1837 ****

// check for dict type
type = get_type_on_stack(cctx, 0);
! if (type->tt_type != VAR_DICT && type != &t_any && type != &t_unknown)
{
char *tofree;

--- 1831,1838 ----

// check for dict type
type = get_type_on_stack(cctx, 0);
! if (type->tt_type != VAR_DICT
! && type->tt_type != VAR_ANY && type->tt_type != VAR_UNKNOWN)
{
char *tofree;

***************
*** 1843,1849 ****
// change dict type to dict member type
if (type->tt_type == VAR_DICT)
{
! type_T *ntype = type->tt_member == &t_unknown
? &t_any : type->tt_member;
set_type_on_stack(cctx, ntype, 0);
}
--- 1844,1850 ----
// change dict type to dict member type
if (type->tt_type == VAR_DICT)
{
! type_T *ntype = type->tt_member->tt_type == VAR_UNKNOWN
? &t_any : type->tt_member;
set_type_on_stack(cctx, ntype, 0);
}
*** ../vim-9.0.0694/src/testdir/test_vim9_script.vim 2022-09-29 19:14:37.679876726 +0100
--- src/testdir/test_vim9_script.vim 2022-10-08 14:08:26.938077306 +0100
***************
*** 297,302 ****
--- 297,310 ----
constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3})
END
v9.CheckDefAndScriptSuccess(lines)
+
+ # "any" type with const flag is recognized as "any"
+ lines =<< trim END
+ const dict: dict<any> = {foo: {bar: 42}}
+ const foo = dict.foo
+ assert_equal(v:t_number, type(foo.bar))
+ END
+ v9.CheckDefAndScriptSuccess(lines)
enddef

def Test_const_bang()
*** ../vim-9.0.0694/src/version.c 2022-10-08 13:49:41.893378443 +0100
--- src/version.c 2022-10-08 14:06:27.774483633 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 695,
/**/

--
I have to exercise early in the morning before my brain
figures out what I'm doing.

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