Mercurial > vim
diff src/testdir/test_vim9_script.vim @ 20871:65d9189d4dca v8.2.0987
patch 8.2.0987: Vim9: cannot assign to [var; var]
Commit: https://github.com/vim/vim/commit/9af78769eeae0318e07aa8b6af4d6e2244481ca7
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 16 11:34:42 2020 +0200
patch 8.2.0987: Vim9: cannot assign to [var; var]
Problem: Vim9: cannot assign to [var; var].
Solution: Assign rest of items to a list.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 16 Jun 2020 11:45:04 +0200 |
parents | 876e16c48bd1 |
children | 58137dbee8da |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -226,9 +226,23 @@ enddef def Test_assignment_var_list() let v1: string let v2: string + let vrem: list<string> + [v1] = ['aaa'] + assert_equal('aaa', v1) + [v1, v2] = ['one', 'two'] assert_equal('one', v1) assert_equal('two', v2) + + [v1, v2; vrem] = ['one', 'two'] + assert_equal('one', v1) + assert_equal('two', v2) + assert_equal([], vrem) + + [v1, v2; vrem] = ['one', 'two', 'three'] + assert_equal('one', v1) + assert_equal('two', v2) + assert_equal(['three'], vrem) enddef def Mess(): string @@ -244,7 +258,18 @@ def Test_assignment_failure() call CheckDefFailure(['let true = 1'], 'E1034:') call CheckDefFailure(['let false = 1'], 'E1034:') - call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:') + call CheckDefFailure(['[a; b; c] = g:list'], 'E452:') + call CheckDefExecFailure(['let a: number', + '[a] = test_null_list()'], 'E1093:') + call CheckDefExecFailure(['let a: number', + '[a] = []'], 'E1093:') + call CheckDefExecFailure(['let x: number', + 'let y: number', + '[x, y] = [1]'], 'E1093:') + call CheckDefExecFailure(['let x: number', + 'let y: number', + 'let z: list<number>', + '[x, y; z] = [1]'], 'E1093:') call CheckDefFailure(['let somevar'], "E1022:") call CheckDefFailure(['let &option'], 'E1052:')