# HG changeset patch # User Bram Moolenaar # Date 1646856003 -3600 # Node ID 21cc8371e45e2bf772dd592bc3acbd8fc8c0442d # Parent d10a46c89635ae8620ac7df3235e2adb639a8805 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 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. diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- 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 = {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 + l = null_list + l = ['text'] + END + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected list but got list') + + lines =<< trim END + var d: dict + d = null_dict + d = {a: 1, b: 2} + END + v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected dict but got dict') +enddef + def Test_skipped_assignment() var lines =<< trim END for x in [] diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4533, +/**/ 4532, /**/ 4531,