mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.1290: Vim9: cannot replace a global function
Problem: Vim9: cannot replace a global function. Solution: Allow for "!" on a global function. (closes #6524) Also fix that :delfunc on a :def function only made it empty.
This commit is contained in:
@@ -468,6 +468,54 @@ def Test_delfunction()
|
||||
'enddef',
|
||||
'DoThat()',
|
||||
], 'E1084:')
|
||||
|
||||
# Check that global :def function can be replaced and deleted
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
def g:Global(): string
|
||||
return "yes"
|
||||
enddef
|
||||
assert_equal("yes", g:Global())
|
||||
def! g:Global(): string
|
||||
return "no"
|
||||
enddef
|
||||
assert_equal("no", g:Global())
|
||||
delfunc g:Global
|
||||
assert_false(exists('*g:Global'))
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
|
||||
# Check that global function can be replaced by a :def function and deleted
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
func g:Global()
|
||||
return "yes"
|
||||
endfunc
|
||||
assert_equal("yes", g:Global())
|
||||
def! g:Global(): string
|
||||
return "no"
|
||||
enddef
|
||||
assert_equal("no", g:Global())
|
||||
delfunc g:Global
|
||||
assert_false(exists('*g:Global'))
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
|
||||
# Check that global :def function can be replaced by a function and deleted
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
def g:Global(): string
|
||||
return "yes"
|
||||
enddef
|
||||
assert_equal("yes", g:Global())
|
||||
func! g:Global()
|
||||
return "no"
|
||||
endfunc
|
||||
assert_equal("no", g:Global())
|
||||
delfunc g:Global
|
||||
assert_false(exists('*g:Global'))
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
func Test_wrong_type()
|
||||
|
Reference in New Issue
Block a user