patch 9.0.1320: checking the type of a null object causes a crash
Problem: Checking the type of a null object causes a crash.
Solution: Don't try to get the class of a null object. (closes #12005)
Handle error from calling a user function better.
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index e73b31c..2cd3bdd 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -195,6 +195,26 @@
echo db[state.value]
END
v9.CheckScriptFailure(lines, 'E1360:')
+
+ lines =<< trim END
+ vim9script
+
+ class Background
+ this.background = 'dark'
+ endclass
+
+ class Colorscheme
+ this._bg: Background
+
+ def GetBackground(): string
+ return this._bg.background
+ enddef
+ endclass
+
+ var bg: Background # UNINITIALIZED
+ echo Colorscheme.new(bg).GetBackground()
+ END
+ v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Background> but got object<Unknown>')
enddef
def Test_class_member_initializer()