forked from aniani/vim
patch 9.0.1375: crash when getting member of obj of unknown class
Problem: Crash when getting member of obj of unknown class. Solution: Check for NULL class and give an error message. (Ernie Rael, closes #12096)
This commit is contained in:
committed by
Bram Moolenaar
parent
c727b19e9f
commit
f77a7f704f
@@ -3452,4 +3452,6 @@ EXTERN char e_cannot_use_color_none_did_you_mean_none[]
|
||||
#ifdef FEAT_EVAL
|
||||
EXTERN char e_cannot_use_non_null_object[]
|
||||
INIT(= N_("E1362: Cannot use a non-null object"));
|
||||
EXTERN char e_incomplete_type[]
|
||||
INIT(= N_("E1363: Incomplete type"));
|
||||
#endif
|
||||
|
@@ -272,6 +272,25 @@ def Test_object_not_set()
|
||||
echo Colorscheme.new(bg).GetBackground()
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Background> but got object<Unknown>')
|
||||
|
||||
# TODO: this should not give an error but be handled at runtime
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
|
||||
class Class
|
||||
this.id: string
|
||||
def Method1()
|
||||
echo 'Method1' .. this.id
|
||||
enddef
|
||||
endclass
|
||||
|
||||
var obj = null_object
|
||||
def Func()
|
||||
obj.Method1()
|
||||
enddef
|
||||
Func()
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1363:')
|
||||
enddef
|
||||
|
||||
def Test_class_member_initializer()
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1375,
|
||||
/**/
|
||||
1374,
|
||||
/**/
|
||||
|
@@ -293,6 +293,13 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
|
||||
}
|
||||
}
|
||||
|
||||
if (cl == NULL)
|
||||
{
|
||||
// TODO: this should not give an error but be handled at runtime
|
||||
emsg(_(e_incomplete_type));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
++*arg;
|
||||
char_u *name = *arg;
|
||||
char_u *name_end = find_name_end(name, NULL, NULL, FNE_CHECK_START);
|
||||
|
Reference in New Issue
Block a user