Mercurial > vim
changeset 28017:21cc8371e45e v8.2.4533
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Commit: https://github.com/vim/vim/commit/56b84b1728e68f984446ec2698716cb8a1f6871d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 9 19:46:48 2022 +0000
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Problem: Vim9: no test that after assigning null the type is still checked.
Solution: Add a test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 09 Mar 2022 21:00:03 +0100 |
parents | d10a46c89635 |
children | 3aa327f5e4c6 |
files | src/testdir/test_vim9_assign.vim src/version.c |
diffstat | 2 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -340,10 +340,35 @@ def Test_null_values() var j: job = null_job var c: channel = null_channel endif + + var d: dict<func> = {a: function('tr'), b: null_function} END v9.CheckDefAndScriptSuccess(lines) enddef +def Test_keep_type_after_assigning_null() + var lines =<< trim END + var b: blob + b = null_blob + b = 'text' + END + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected blob but got string') + + lines =<< trim END + var l: list<number> + l = null_list + l = ['text'] + END + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected list<number> but got list<string>') + + lines =<< trim END + var d: dict<string> + d = null_dict + d = {a: 1, b: 2} + END + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got dict<number>') +enddef + def Test_skipped_assignment() var lines =<< trim END for x in []