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

patch 8.2.3023: Vim9: arguments for execute() not checked at compile time

Problem:    Vim9: arguments for execute() not checked at compile time.
Solution:   Add a function to check the argument types.
This commit is contained in:
Bram Moolenaar
2021-06-20 14:41:01 +02:00
parent f573c6e1ed
commit ca81f0e834
3 changed files with 37 additions and 1 deletions

View File

@@ -324,6 +324,18 @@ def Test_executable()
CheckDefExecFailure(['echo executable(true)'], 'E1174:')
enddef
def Test_execute()
var res = execute("echo 'hello'")
assert_equal("\nhello", res)
res = execute(["echo 'here'", "echo 'there'"])
assert_equal("\nhere\nthere", res)
CheckDefFailure(['echo execute(123)'], 'E1013: Argument 1: type mismatch, expected string but got number')
CheckDefFailure(['echo execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492')
CheckDefFailure(['echo execute("xx", 123)'], 'E1013: Argument 2: type mismatch, expected string but got number')
enddef
def Test_exepath()
CheckDefExecFailure(['echo exepath(true)'], 'E1174:')
CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:')