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)
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index c228f26..bc8a8e1 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -272,6 +272,25 @@
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()