patch 8.2.2549: crash after using "g:" in a for loop
Problem: Crash after using "g:" in a for loop.
Solution: Increment the reference count. (closes #7892)
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 3e69a0d..cda1ffd 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2545,6 +2545,12 @@
assert_equal('some', get(t:, 'some_var', 'xxx'))
assert_equal('xxx', get(t:, 'no_var', 'xxx'))
unlet t:some_var
+
+ # check using g: in a for loop more than DO_NOT_FREE_CNT times
+ for i in range(100000)
+ if has_key(g:, 'does-not-exist')
+ endif
+ endfor
enddef
def Test_expr7_parens()