Skip to content

Commit f5d52c9

Browse files
committed
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Problem: Vim9: "..=" does not accept same types as the ".." operator. Solution: Convert value to string like ".." does. (issue #8664)
1 parent 9e0ee59 commit f5d52c9

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

src/testdir/test_vim9_assign.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,32 @@ def Test_assignment()
239239
END
240240
enddef
241241

242+
let g:someNumber = 43
243+
244+
def Test_assign_concat()
245+
var lines =<< trim END
246+
var s = '-'
247+
s ..= 99
248+
s ..= true
249+
s ..= '-'
250+
s ..= v:null
251+
s ..= g:someNumber
252+
assert_equal('-99true-null43', s)
253+
END
254+
CheckDefAndScriptSuccess(lines)
255+
256+
lines =<< trim END
257+
var s = '-'
258+
s ..= [1, 2]
259+
END
260+
CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert list to string', 'E734: Wrong variable type for .=', 2)
261+
lines =<< trim END
262+
var s = '-'
263+
s ..= {a: 2}
264+
END
265+
CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert dict to string', 'E734: Wrong variable type for .=', 2)
266+
enddef
267+
242268
def Test_assign_register()
243269
var lines =<< trim END
244270
@c = 'areg'

src/testdir/test_vim9_disassemble.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ def Test_disassemble_for_loop_eval()
12541254
'res ..= str\_s*' ..
12551255
'\d\+ LOAD $0\_s*' ..
12561256
'\d\+ LOAD $2\_s*' ..
1257-
'\d\+ CHECKTYPE string stack\[-1\]\_s*' ..
1257+
'\d 2STRING_ANY stack\[-1\]\_s*' ..
12581258
'\d\+ CONCAT\_s*' ..
12591259
'\d\+ STORE $0\_s*' ..
12601260
'endfor\_s*' ..

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3263,
758760
/**/
759761
3262,
760762
/**/

src/vim9compile.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7086,18 +7086,23 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
70867086
type_T *stacktype;
70877087

70887088
if (*op == '.')
7089-
expected = &t_string;
7089+
{
7090+
if (may_generate_2STRING(-1, FALSE, cctx) == FAIL)
7091+
goto theend;
7092+
}
70907093
else
7094+
{
70917095
expected = lhs.lhs_member_type;
7092-
stacktype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
7093-
if (
7096+
stacktype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
7097+
if (
70947098
#ifdef FEAT_FLOAT
7095-
// If variable is float operation with number is OK.
7096-
!(expected == &t_float && stacktype == &t_number) &&
7099+
// If variable is float operation with number is OK.
7100+
!(expected == &t_float && stacktype == &t_number) &&
70977101
#endif
70987102
need_type(stacktype, expected, -1, 0, cctx,
70997103
FALSE, FALSE) == FAIL)
7100-
goto theend;
7104+
goto theend;
7105+
}
71017106

71027107
if (*op == '.')
71037108
{

0 commit comments

Comments
 (0)