mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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,19 +2252,6 @@ 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 == '.'
|
|
||||||
&& (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()
|
|
||||||
// class constructor: SomeClass.new()
|
|
||||||
// object member: someObject.varname, this.varname
|
|
||||||
// object method: someObject.SomeMethod(), this.SomeMethod()
|
|
||||||
*arg = p;
|
|
||||||
if (compile_class_object_index(cctx, arg, type) == FAIL)
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
else if (*p == '.' && p[1] != '.')
|
else if (*p == '.' && p[1] != '.')
|
||||||
{
|
{
|
||||||
// dictionary member: dict.name
|
// dictionary member: dict.name
|
||||||
@@ -2272,27 +2259,43 @@ compile_subscript(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
ppconst->pp_is_const = FALSE;
|
ppconst->pp_is_const = FALSE;
|
||||||
|
|
||||||
*arg = p + 1;
|
if ((type = get_type_on_stack(cctx, 0)) != &t_unknown
|
||||||
if (IS_WHITE_OR_NUL(**arg))
|
&& (type->tt_type == VAR_CLASS
|
||||||
|
|| type->tt_type == VAR_OBJECT))
|
||||||
{
|
{
|
||||||
emsg(_(e_missing_name_after_dot));
|
// class member: SomeClass.varname
|
||||||
return FAIL;
|
// class method: SomeClass.SomeMethod()
|
||||||
|
// class constructor: SomeClass.new()
|
||||||
|
// object member: someObject.varname, this.varname
|
||||||
|
// object method: someObject.SomeMethod(), this.SomeMethod()
|
||||||
|
*arg = p;
|
||||||
|
if (compile_class_object_index(cctx, arg, type) == FAIL)
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
p = *arg;
|
else
|
||||||
if (eval_isdictc(*p))
|
|
||||||
while (eval_isnamec(*p))
|
|
||||||
MB_PTR_ADV(p);
|
|
||||||
if (p == *arg)
|
|
||||||
{
|
{
|
||||||
semsg(_(e_syntax_error_at_str), *arg);
|
*arg = p + 1;
|
||||||
return FAIL;
|
if (IS_WHITE_OR_NUL(**arg))
|
||||||
|
{
|
||||||
|
emsg(_(e_missing_name_after_dot));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
p = *arg;
|
||||||
|
if (eval_isdictc(*p))
|
||||||
|
while (eval_isnamec(*p))
|
||||||
|
MB_PTR_ADV(p);
|
||||||
|
if (p == *arg)
|
||||||
|
{
|
||||||
|
semsg(_(e_syntax_error_at_str), *arg);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if (keeping_dict && generate_instr(cctx, ISN_CLEARDICT) == NULL)
|
||||||
|
return FAIL;
|
||||||
|
if (generate_STRINGMEMBER(cctx, *arg, p - *arg) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
keeping_dict = TRUE;
|
||||||
|
*arg = p;
|
||||||
}
|
}
|
||||||
if (keeping_dict && generate_instr(cctx, ISN_CLEARDICT) == NULL)
|
|
||||||
return FAIL;
|
|
||||||
if (generate_STRINGMEMBER(cctx, *arg, p - *arg) == FAIL)
|
|
||||||
return FAIL;
|
|
||||||
keeping_dict = TRUE;
|
|
||||||
*arg = p;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user