patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Problem: Vim9: problem defining a script variable from legacy function.
Solution: Check if the script is Vim9, not the current syntax.
(closes #8032)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 1169c86..cd8ac09 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -3220,6 +3220,35 @@
delete('Xvim9_script.vim')
enddef
+def Test_declare_script_in_func()
+ var lines =<< trim END
+ vim9script
+ func Declare()
+ let s:local = 123
+ endfunc
+ Declare()
+ assert_equal(123, local)
+
+ var error: string
+ try
+ local = 'asdf'
+ catch
+ error = v:exception
+ endtry
+ assert_match('E1012: Type mismatch; expected number but got string', error)
+
+ lockvar local
+ try
+ local = 999
+ catch
+ error = v:exception
+ endtry
+ assert_match('E741: Value is locked: local', error)
+ END
+ CheckScriptSuccess(lines)
+enddef
+
+
func Test_vim9script_not_global()
" check that items defined in Vim9 script are script-local, not global
let vim9lines =<< trim END