patch 8.2.1859: Vim9: crash in unpack assignment
Problem: Vim9: crash in unpack assignment.
Solution: Make sure an error message is turned into an exception.
(closes #7159)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 9a2a481..21de344 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -620,6 +620,7 @@
lines =<< trim END
vim9script
+ @r = ''
def Func()
throw @r
enddef
@@ -2818,6 +2819,27 @@
CheckScriptFailure(lines, 'E121:', 6)
enddef
+def Test_catch_exception_in_callback()
+ var lines =<< trim END
+ vim9script
+ def Callback(...l: any)
+ try
+ var x: string
+ var y: string
+ # this error should be caught with CHECKLEN
+ [x, y] = ['']
+ catch
+ g:caught = 'yes'
+ endtry
+ enddef
+ popup_menu('popup', #{callback: Callback})
+ feedkeys("\r", 'xt')
+ END
+ CheckScriptSuccess(lines)
+
+ unlet g:caught
+enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new