Patch 8.2.1730
Problem: Vim9: cannot use member of unknown type.
Solution: When type is unknown us "any". (closes #6997)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.1729/src/vim9compile.c 2020-09-21 20:35:51.675186059 +0200
--- src/vim9compile.c 2020-09-23 13:14:04.290665574 +0200
***************
*** 5080,5091 ****
}
else
{
! // An empty list or dict has a &t_void member,
// for a variable that implies &t_any.
if (stacktype == &t_list_empty)
lvar->lv_type = &t_list_any;
else if (stacktype == &t_dict_empty)
lvar->lv_type = &t_dict_any;
else
lvar->lv_type = stacktype;
}
--- 5080,5093 ----
}
else
{
! // An empty list or dict has a &t_unknown member,
// for a variable that implies &t_any.
if (stacktype == &t_list_empty)
lvar->lv_type = &t_list_any;
else if (stacktype == &t_dict_empty)
lvar->lv_type = &t_dict_any;
+ else if (stacktype == &t_unknown)
+ lvar->lv_type = &t_any;
else
lvar->lv_type = stacktype;
}
*** ../vim-8.2.1729/src/testdir/test_vim9_assign.vim 2020-09-21
22:21:15.167008475 +0200
--- src/testdir/test_vim9_assign.vim 2020-09-23 13:22:36.051783782 +0200
***************
*** 676,681 ****
--- 676,708 ----
assert_equal({'0': 0, '1': 1, '2': 2}, nrd)
enddef
+ def Test_assign_dict_unknown_type()
+ let lines =<< trim END
+ vim9script
+ let mylist = []
+ mylist += [#{one: 'one'}]
+ def Func()
+ let dd = mylist[0]
+ assert_equal('one', dd.one)
+ enddef
+ Func()
+ END
+ CheckScriptSuccess(lines)
+
+ # doesn't work yet
+ #lines =<< trim END
+ # vim9script
+ # let mylist = [[]]
+ # mylist[0] += [#{one: 'one'}]
+ # def Func()
+ # let dd = mylist[0][0]
+ # assert_equal('one', dd.one)
+ # enddef
+ # Func()
+ #END
+ #CheckScriptSuccess(lines)
+ enddef
+
def Test_assign_lambda()
# check if assign a lambda to a variable which type is func or any.
let lines =<< trim END
*** ../vim-8.2.1729/src/version.c 2020-09-23 12:28:46.429897985 +0200
--- src/version.c 2020-09-23 13:17:37.713453450 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1730,
/**/
--
Back off man, I'm a scientist.
-- Peter, Ghostbusters
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202009231125.08NBPxA83904651%40masaka.moolenaar.net.