patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Problem: Vim9: return type of maparg() not adjusted for fourth argument.
Solution: Check if fourth argument is present. (closes #6645)
diff --git a/src/testdir/test_maparg.vim b/src/testdir/test_maparg.vim
index 81e057a..3b61ff6 100644
--- a/src/testdir/test_maparg.vim
+++ b/src/testdir/test_maparg.vim
@@ -81,6 +81,19 @@
abclear
endfunc
+def Test_vim9_maparg()
+ nmap { w
+ let one: string = maparg('{')
+ assert_equal('w', one)
+ let two: string = maparg('{', 'n')
+ assert_equal('w', two)
+ let three: string = maparg('{', 'n', 0)
+ assert_equal('w', three)
+ let four: dict<any> = maparg('{', 'n', 0, 1)
+ call assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode])
+ nunmap {
+enddef
+
func Test_mapcheck()
call assert_equal('', mapcheck('a'))
call assert_equal('', mapcheck('abc'))