Problem: Crash when getting member of obj of unknown class.
Solution: Check for NULL class and give an error message. (Ernie Rael,
closes #12096)
#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
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()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1375,
/**/
1374,
/**/
}
}
+ 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);