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)
|
||||
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()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1204,
|
||||
/**/
|
||||
1203,
|
||||
/**/
|
||||
|
@@ -2252,9 +2252,16 @@ compile_subscript(
|
||||
if (compile_member(is_slice, &keeping_dict, cctx) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
else if (*p == '.'
|
||||
&& (type = get_type_on_stack(cctx, 0)) != &t_unknown
|
||||
&& (type->tt_type == VAR_CLASS || type->tt_type == VAR_OBJECT))
|
||||
else if (*p == '.' && p[1] != '.')
|
||||
{
|
||||
// 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 method: SomeClass.SomeMethod()
|
||||
@@ -2265,13 +2272,8 @@ compile_subscript(
|
||||
if (compile_class_object_index(cctx, arg, type) == 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;
|
||||
if (IS_WHITE_OR_NUL(**arg))
|
||||
{
|
||||
@@ -2294,6 +2296,7 @@ compile_subscript(
|
||||
keeping_dict = TRUE;
|
||||
*arg = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user