]> granicus.if.org Git - vim/commitdiff
patch 8.2.4533: Vim9: no test that after assigning null type is still checked v8.2.4533
authorBram Moolenaar <Bram@vim.org>
Wed, 9 Mar 2022 19:46:48 +0000 (19:46 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 9 Mar 2022 19:46:48 +0000 (19:46 +0000)
Problem:    Vim9: no test that after assigning null the type is still checked.
Solution:   Add a test.

src/testdir/test_vim9_assign.vim
src/version.c

index abc3a15b9a3d894f06741f1b12a780aa216c214c..21a39e1f6b9d0515db2baefad4c73af260ee247a 100644 (file)
@@ -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 []
index 9248ca4031eb0ba82b65d95001692dd45e49488c..9b72517a5d51e9cbd61c3b4b4323b3f9f9bd2146 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4533,
 /**/
     4532,
 /**/