Commit: patch 9.1.1527: Vim9: Crash with string compound assignment

5 views
Skip to first unread message

Christian Brabandt

unread,
Jul 8, 2025, 4:00:17 PM7/8/25
to vim...@googlegroups.com
patch 9.1.1527: Vim9: Crash with string compound assignment

Commit: https://github.com/vim/vim/commit/2ffd35fe8fade8f08eadf6b41b40e55b155424b8
Author: Hirohito Higashi <h.eas...@gmail.com>
Date: Tue Jul 8 21:47:01 2025 +0200

patch 9.1.1527: Vim9: Crash with string compound assignment

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.eas...@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yega...@yahoo.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index c0f56d9cb..e95506407 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -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:')
diff --git a/src/version.c b/src/version.c
index 5a7225b7c..c84096053 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1527,
/**/
1526,
/**/
diff --git a/src/vim9compile.c b/src/vim9compile.c
index b3cf86c98..131bab7f4 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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
Reply all
Reply to author
Forward
0 new messages