Mercurial > vim
diff src/testdir/test_vim9_assign.vim @ 28345:fabe722b24e9 v8.2.4698
patch 8.2.4698: Vim9: script variable has no flag that it was set
Commit: https://github.com/vim/vim/commit/aa7d0c233532fb9d8c2876ea8e978a82b12c377f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 5 21:40:38 2022 +0100
patch 8.2.4698: Vim9: script variable has no flag that it was set
Problem: Vim9: script variable has no flag that it was set.
Solution: Add a flag that it was set, to avoid giving it a value when used.
(closes #10088)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 05 Apr 2022 22:45:03 +0200 |
parents | fff70771d4bb |
children | 769599ee9f06 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -740,6 +740,7 @@ def Test_init_in_for_loop() enddef def Test_extend_list() + # using uninitilaized list assigns empty list var lines =<< trim END var l1: list<number> var l2 = l1 @@ -757,7 +758,7 @@ def Test_extend_list() END v9.CheckDefAndScriptSuccess(lines) - # appending to NULL list from a function + # appending to uninitialzed list from a function works lines =<< trim END vim9script var list: list<string> @@ -779,13 +780,30 @@ def Test_extend_list() END v9.CheckScriptSuccess(lines) + # initialized to null, with type, does not default to empty list lines =<< trim END vim9script var l: list<string> = test_null_list() extend(l, ['x']) - assert_equal(['x'], l) + END + v9.CheckScriptFailure(lines, 'E1134:', 3) + + # initialized to null, without type, does not default to empty list + lines =<< trim END + vim9script + var l = null_list + extend(l, ['x']) END - v9.CheckScriptSuccess(lines) + v9.CheckScriptFailure(lines, 'E1134:', 3) + + # assigned null, does not default to empty list + lines =<< trim END + vim9script + var l: list<string> + l = null_list + extend(l, ['x']) + END + v9.CheckScriptFailure(lines, 'E1134:', 4) lines =<< trim END vim9script @@ -838,9 +856,8 @@ def Test_extend_dict() vim9script var d: dict<string> = test_null_dict() extend(d, {a: 'x'}) - assert_equal({a: 'x'}, d) END - v9.CheckScriptSuccess(lines) + v9.CheckScriptFailure(lines, 'E1133:', 3) lines =<< trim END vim9script