]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1527: Vim9: Crash with string compound assignment v9.1.1527
authorHirohito Higashi <h.east.727@gmail.com>
Tue, 8 Jul 2025 19:47:01 +0000 (21:47 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 8 Jul 2025 19:49:56 +0000 (21:49 +0200)
Problem:  Vim9: Crash when using string compound assignment with wrong
          data type (lacygoill)
Solution: verify expected member type (Hirohito Higashi)

fixes: #17675
closes: #17693

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_assign.vim
src/version.c
src/vim9compile.c

index c0f56d9cb440f14e1ce005fb408230b19903b3af..e955064074dd7490967ff7f2dd2433f41144186c 100644 (file)
@@ -187,6 +187,7 @@ def Test_assignment()
 
   v9.CheckDefFailure(['&notex += 3'], 'E113:')
   v9.CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
+  v9.CheckDefFailure(['var d = {k: [0]}', 'd.k ..= "x"'], 'E1012: Type mismatch; expected list<number> but got string')
   v9.CheckDefFailure(['&ts = [7]'], 'E1012:')
   v9.CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list<number>')
   v9.CheckDefFailure(['&ts = "xx"'], 'E1012:')
index 5a7225b7cec4611f94ae3109112120d1faf9a594..c84096053ca3a35a651be2a035915f35e3cb645b 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1527,
 /**/
     1526,
 /**/
index b3cf86c98dac6a42e42b7e7a08c131987b9e0444..131bab7f47fabbcd8b7723ece0843bfcc6ed260a 100644 (file)
@@ -3444,7 +3444,13 @@ compile_assign_compound_op(cctx_T *cctx, cac_T *cac)
 
     if (*cac->cac_op == '.')
     {
-       if (may_generate_2STRING(-1, TOSTRING_NONE, cctx) == FAIL)
+       expected = lhs->lhs_member_type;
+       stacktype = get_type_on_stack(cctx, 0);
+       if (expected != &t_string
+               && need_type(stacktype, expected, FALSE, -1, 0, cctx,
+                                       FALSE, FALSE) == FAIL)
+           return FAIL;
+       else if (may_generate_2STRING(-1, TOSTRING_NONE, cctx) == FAIL)
            return FAIL;
     }
     else