mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.1317: crash when using an unset object variable
Problem: Crash when using an unset object variable. Solution: Give an error instead. (closes #12005)
This commit is contained in:
@@ -1182,6 +1182,8 @@ EXTERN char e_invalid_command[]
|
|||||||
INIT(= N_("E476: Invalid command"));
|
INIT(= N_("E476: Invalid command"));
|
||||||
EXTERN char e_invalid_command_str[]
|
EXTERN char e_invalid_command_str[]
|
||||||
INIT(= N_("E476: Invalid command: %s"));
|
INIT(= N_("E476: Invalid command: %s"));
|
||||||
|
EXTERN char e_invalid_command_str_expected_str[]
|
||||||
|
INIT(= N_("E476: Invalid command: %s, expected %s"));
|
||||||
EXTERN char e_no_bang_allowed[]
|
EXTERN char e_no_bang_allowed[]
|
||||||
INIT(= N_("E477: No ! allowed"));
|
INIT(= N_("E477: No ! allowed"));
|
||||||
EXTERN char e_dont_panic[]
|
EXTERN char e_dont_panic[]
|
||||||
@@ -3442,6 +3444,6 @@ EXTERN char e_using_super_not_in_child_class[]
|
|||||||
INIT(= N_("E1358: Using \"super\" not in a child class"));
|
INIT(= N_("E1358: Using \"super\" not in a child class"));
|
||||||
EXTERN char e_cannot_define_new_function_in_abstract_class[]
|
EXTERN char e_cannot_define_new_function_in_abstract_class[]
|
||||||
INIT(= N_("E1359: Cannot define a \"new\" function in an abstract class"));
|
INIT(= N_("E1359: Cannot define a \"new\" function in an abstract class"));
|
||||||
EXTERN char e_invalid_command_str_expected_str[]
|
EXTERN char e_using_null_object[]
|
||||||
INIT(= N_("E476: Invalid command: %s, expected %s"));
|
INIT(= N_("E1360: Using a null object"));
|
||||||
#endif
|
#endif
|
||||||
|
@@ -182,6 +182,21 @@ def Test_class_interface_wrong_end()
|
|||||||
v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface')
|
v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_object_not_set()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
class State
|
||||||
|
this.value = 'xyz'
|
||||||
|
endclass
|
||||||
|
|
||||||
|
var state: State
|
||||||
|
var db = {'xyz': 789}
|
||||||
|
echo db[state.value]
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1360:')
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_class_member_initializer()
|
def Test_class_member_initializer()
|
||||||
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 */
|
||||||
|
/**/
|
||||||
|
1317,
|
||||||
/**/
|
/**/
|
||||||
1316,
|
1316,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1234,9 +1234,6 @@ class_object_index(
|
|||||||
evalarg_T *evalarg,
|
evalarg_T *evalarg,
|
||||||
int verbose UNUSED) // give error messages
|
int verbose UNUSED) // give error messages
|
||||||
{
|
{
|
||||||
// int evaluate = evalarg != NULL
|
|
||||||
// && (evalarg->eval_flags & EVAL_EVALUATE);
|
|
||||||
|
|
||||||
if (VIM_ISWHITE((*arg)[1]))
|
if (VIM_ISWHITE((*arg)[1]))
|
||||||
{
|
{
|
||||||
semsg(_(e_no_white_space_allowed_after_str_str), ".", *arg);
|
semsg(_(e_no_white_space_allowed_after_str_str), ".", *arg);
|
||||||
@@ -1250,8 +1247,19 @@ class_object_index(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
size_t len = name_end - name;
|
size_t len = name_end - name;
|
||||||
|
|
||||||
class_T *cl = rettv->v_type == VAR_CLASS ? rettv->vval.v_class
|
class_T *cl;
|
||||||
: rettv->vval.v_object->obj_class;
|
if (rettv->v_type == VAR_CLASS)
|
||||||
|
cl = rettv->vval.v_class;
|
||||||
|
else // VAR_OBJECT
|
||||||
|
{
|
||||||
|
if (rettv->vval.v_object == NULL)
|
||||||
|
{
|
||||||
|
emsg(_(e_using_null_object));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
cl = rettv->vval.v_object->obj_class;
|
||||||
|
}
|
||||||
|
|
||||||
if (*name_end == '(')
|
if (*name_end == '(')
|
||||||
{
|
{
|
||||||
int on_class = rettv->v_type == VAR_CLASS;
|
int on_class = rettv->v_type == VAR_CLASS;
|
||||||
|
Reference in New Issue
Block a user