mirror of
https://github.com/vim/vim.git
synced 2025-10-01 04:54:07 -04:00
patch 9.0.0695: failing check for dictionary type for const any
Problem: Failing check for dictionary type for const any. Solution: Check for any type properly. (closes #11310)
This commit is contained in:
@@ -297,6 +297,14 @@ def Test_const()
|
|||||||
constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3})
|
constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3})
|
||||||
END
|
END
|
||||||
v9.CheckDefAndScriptSuccess(lines)
|
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
|
enddef
|
||||||
|
|
||||||
def Test_const_bang()
|
def Test_const_bang()
|
||||||
|
@@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
695,
|
||||||
/**/
|
/**/
|
||||||
694,
|
694,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1831,7 +1831,8 @@ generate_STRINGMEMBER(cctx_T *cctx, char_u *name, size_t len)
|
|||||||
|
|
||||||
// check for dict type
|
// check for dict type
|
||||||
type = get_type_on_stack(cctx, 0);
|
type = get_type_on_stack(cctx, 0);
|
||||||
if (type->tt_type != VAR_DICT && type != &t_any && type != &t_unknown)
|
if (type->tt_type != VAR_DICT
|
||||||
|
&& type->tt_type != VAR_ANY && type->tt_type != VAR_UNKNOWN)
|
||||||
{
|
{
|
||||||
char *tofree;
|
char *tofree;
|
||||||
|
|
||||||
@@ -1843,7 +1844,7 @@ generate_STRINGMEMBER(cctx_T *cctx, char_u *name, size_t len)
|
|||||||
// change dict type to dict member type
|
// change dict type to dict member type
|
||||||
if (type->tt_type == VAR_DICT)
|
if (type->tt_type == VAR_DICT)
|
||||||
{
|
{
|
||||||
type_T *ntype = type->tt_member == &t_unknown
|
type_T *ntype = type->tt_member->tt_type == VAR_UNKNOWN
|
||||||
? &t_any : type->tt_member;
|
? &t_any : type->tt_member;
|
||||||
set_type_on_stack(cctx, ntype, 0);
|
set_type_on_stack(cctx, ntype, 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user