patch 8.2.2944: Vim9: no error when using job or channel as a string
Problem: Vim9: no error when using job or channel as a string.
Solution: Be more strict about conversion to string. (closes #8312)
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 9cae4a3..b98c840 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1104,7 +1104,7 @@
assert_equal([], getbufline(b, 2, 1))
if has('job')
- setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()])
+ setbufline(b, 2, [function('eval'), {key: 123}, string(test_null_job())])
assert_equal(["function('eval')",
"{'key': 123}",
"no process"],
@@ -1250,6 +1250,16 @@
actual->assert_equal(expected)
enddef
+def Test_substitute()
+ var res = substitute('A1234', '\d', 'X', '')
+ assert_equal('AX234', res)
+
+ if has('job')
+ assert_fails('"text"->substitute(".*", () => job_start(":"), "")', 'E908: using an invalid value as a String: job')
+ assert_fails('"text"->substitute(".*", () => job_start(":")->job_getchannel(), "")', 'E908: using an invalid value as a String: channel')
+ endif
+enddef
+
def Test_synID()
new
setline(1, "text")