0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

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:
Ernie Rael
2023-03-03 15:05:30 +00:00
committed by Bram Moolenaar
parent c727b19e9f
commit f77a7f704f
4 changed files with 30 additions and 0 deletions

View File

@@ -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()