0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.2224: Vim9: crash if script reloaded with different variable type

Problem:    Vim9: crash if script reloaded with different variable type.
Solution:   Check the type when accessing the variable.
This commit is contained in:
Bram Moolenaar
2020-12-26 20:09:15 +01:00
parent cdc40c43f1
commit 07a65d26e7
11 changed files with 105 additions and 47 deletions

View File

@@ -1247,6 +1247,32 @@ def Test_vim9script_reload_import()
delete('Ximport.vim')
enddef
" if a script is reloaded with a script-local variable that changed its type, a
" compiled function using that variable must fail.
def Test_script_reload_change_type()
var lines =<< trim END
vim9script noclear
var str = 'string'
def g:GetStr(): string
return str .. 'xxx'
enddef
END
writefile(lines, 'Xreload.vim')
source Xreload.vim
echo g:GetStr()
lines =<< trim END
vim9script noclear
var str = 1234
END
writefile(lines, 'Xreload.vim')
source Xreload.vim
assert_fails('echo g:GetStr()', 'E1150:')
delfunc g:GetStr
delete('Xreload.vim')
enddef
def s:RetSome(): string
return 'some'
enddef