forked from aniani/vim
patch 9.0.1204: expression compiled the wrong way after using an object
Problem: Expression compiled the wrong way after using an object. Solution: Generate constants before getting the type.
This commit is contained in:
@@ -240,6 +240,25 @@ def Test_list_of_objects()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_expr_after_using_object()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
class Something
|
||||||
|
this.label: string = ''
|
||||||
|
endclass
|
||||||
|
|
||||||
|
def Foo(): Something
|
||||||
|
var v = Something.new()
|
||||||
|
echo 'in Foo(): ' .. typename(v)
|
||||||
|
return v
|
||||||
|
enddef
|
||||||
|
|
||||||
|
Foo()
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_class_default_new()
|
def Test_class_default_new()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
@@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
1204,
|
||||||
/**/
|
/**/
|
||||||
1203,
|
1203,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -2252,9 +2252,16 @@ compile_subscript(
|
|||||||
if (compile_member(is_slice, &keeping_dict, cctx) == FAIL)
|
if (compile_member(is_slice, &keeping_dict, cctx) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else if (*p == '.'
|
else if (*p == '.' && p[1] != '.')
|
||||||
&& (type = get_type_on_stack(cctx, 0)) != &t_unknown
|
{
|
||||||
&& (type->tt_type == VAR_CLASS || type->tt_type == VAR_OBJECT))
|
// dictionary member: dict.name
|
||||||
|
if (generate_ppconst(cctx, ppconst) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
ppconst->pp_is_const = FALSE;
|
||||||
|
|
||||||
|
if ((type = get_type_on_stack(cctx, 0)) != &t_unknown
|
||||||
|
&& (type->tt_type == VAR_CLASS
|
||||||
|
|| type->tt_type == VAR_OBJECT))
|
||||||
{
|
{
|
||||||
// class member: SomeClass.varname
|
// class member: SomeClass.varname
|
||||||
// class method: SomeClass.SomeMethod()
|
// class method: SomeClass.SomeMethod()
|
||||||
@@ -2265,13 +2272,8 @@ compile_subscript(
|
|||||||
if (compile_class_object_index(cctx, arg, type) == FAIL)
|
if (compile_class_object_index(cctx, arg, type) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else if (*p == '.' && p[1] != '.')
|
else
|
||||||
{
|
{
|
||||||
// dictionary member: dict.name
|
|
||||||
if (generate_ppconst(cctx, ppconst) == FAIL)
|
|
||||||
return FAIL;
|
|
||||||
ppconst->pp_is_const = FALSE;
|
|
||||||
|
|
||||||
*arg = p + 1;
|
*arg = p + 1;
|
||||||
if (IS_WHITE_OR_NUL(**arg))
|
if (IS_WHITE_OR_NUL(**arg))
|
||||||
{
|
{
|
||||||
@@ -2294,6 +2296,7 @@ compile_subscript(
|
|||||||
keeping_dict = TRUE;
|
keeping_dict = TRUE;
|
||||||
*arg = p;
|
*arg = p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user