patch 8.2.1446: Vim9: line number in error message is not correct
Problem: Vim9: line number in error message is not correct.
Solution: Set SOURCING_LNUM before calling emsg(). (closes #6708)
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 1f9768f..3e72120 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1045,6 +1045,7 @@
call writefile(lines, 'Xdef')
try
source Xdef
+ assert_report('should have failed')
catch /E476:/
assert_match('Invalid command: invalid', v:exception)
assert_match(', line 3$', v:throwpoint)
@@ -1064,11 +1065,30 @@
call writefile(lines, 'Xdef')
try
source Xdef
+ assert_report('should have failed')
catch /E476:/
assert_match('Invalid command: invalid', v:exception)
assert_match(', line 4$', v:throwpoint)
endtry
+ lines =<< trim END
+ vim9script
+ def Func()
+ let db = #{foo: 1, bar: 2}
+ # comment
+ let x = db.asdf
+ enddef
+ defcompile
+ Func()
+ END
+ call writefile(lines, 'Xdef')
+ try
+ source Xdef
+ assert_report('should have failed')
+ catch /E716:/
+ assert_match('_Func, line 3$', v:throwpoint)
+ endtry
+
call delete('Xdef')
enddef