diff src/testdir/test_vim9_script.vim @ 24460:f0a3adf16f01 v8.2.2770

patch 8.2.2770: Vim9: type of loop variable is not used Commit: https://github.com/vim/vim/commit/fe090eb58fad1aaf83267d0b4ace9f024a5ba2bc Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 15 21:48:32 2021 +0200 patch 8.2.2770: Vim9: type of loop variable is not used Problem: Vim9: type of loop variable is not used. Solution: Parse and check the variable type. (closes https://github.com/vim/vim/issues/8107)
author Bram Moolenaar <Bram@vim.org>
date Thu, 15 Apr 2021 22:00:05 +0200
parents f388a033e568
children e5db23a8ad98
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -2343,6 +2343,12 @@ def Test_for_loop()
       endfor
       assert_equal(6, total)
 
+      var chars = ''
+      for s: string in 'foobar'
+        chars ..= s
+      endfor
+      assert_equal('foobar', chars)
+
       # unpack with type
       var res = ''
       for [n: number, s: string] in [[1, 'a'], [2, 'b']]
@@ -2408,6 +2414,12 @@ def Test_for_loop_fails()
       endfor
   END
   CheckDefAndScriptFailure2(lines, 'E1018:', 'E46:', 3)
+
+  lines =<< trim END
+      for nr: number in ['foo']
+      endfor
+  END
+  CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got string', 1)
 enddef
 
 def Test_for_loop_script_var()