Patch 8.2.3263
Problem:Vim9: "..=" does not accept same types as the ".." operator.
Solution: Convert value to string like ".." does. (issue #8664)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_disassemble.vim
*** ../vim-8.2.3262/src/vim9compile.c 2021-07-28 21:25:45.356602806 +0200
--- src/vim9compile.c 2021-07-31 22:32:30.868941623 +0200
***
*** 7086,7103
type_T *stacktype;
if (*op == '.')
! expected = _string;
else
expected = lhs.lhs_member_type;
! stacktype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
! if (
#ifdef FEAT_FLOAT
! // If variable is float operation with number is OK.
! !(expected == _float && stacktype == _number) &&
#endif
need_type(stacktype, expected, -1, 0, cctx,
FALSE, FALSE) == FAIL)
! goto theend;
if (*op == '.')
{
--- 7086,7108
type_T *stacktype;
if (*op == '.')
! {
! if (may_generate_2STRING(-1, FALSE, cctx) == FAIL)
! goto theend;
! }
else
+ {
expected = lhs.lhs_member_type;
! stacktype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
! if (
#ifdef FEAT_FLOAT
! // If variable is float operation with number is OK.
! !(expected == _float && stacktype == _number) &&
#endif
need_type(stacktype, expected, -1, 0, cctx,
FALSE, FALSE) == FAIL)
! goto theend;
! }
if (*op == '.')
{
*** ../vim-8.2.3262/src/testdir/test_vim9_assign.vim2021-07-28
21:25:45.360602797 +0200
--- src/testdir/test_vim9_assign.vim2021-07-31 22:41:15.279977366 +0200
***
*** 239,244
--- 239,270
END
enddef
+ let g:someNumber = 43
+
+ def Test_assign_concat()
+ var lines =<< trim END
+ var s = '-'
+ s ..= 99
+ s ..= true
+ s ..= '-'
+ s ..= v:null
+ s ..= g:someNumber
+ assert_equal('-99true-null43', s)
+ END
+ CheckDefAndScriptSuccess(lines)
+
+ lines =<< trim END
+ var s = '-'
+ s ..= [1, 2]
+ END
+ CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert list to string',
'E734: Wrong variable type for .=', 2)
+ lines =<< trim END
+ var s = '-'
+ s ..= {a: 2}
+ END
+ CheckDefAndScriptFailure2(lines, 'E1105: Cannot convert dict to string',
'E734: Wrong variable type for .=', 2)
+ enddef
+
def Test_assign_register()
var lines =<< trim END
@c = 'areg'
*** ../vim-8.2.3262/src/testdir/test_vim9_disassemble.vim 2021-06-23
20:20:49.654780609 +0200
--- src/testdir/test_vim9_disassemble.vim 2021-07-31 22:48:34.051077563
+0200
***
*** 1254,1260
'res ..= str\_s*' ..
'\d\+ LOAD $0\_s*' ..
'\d\+ LOAD $2\_s*' ..
! '\d\+ CHECKTYPE string stack\[-1\]\_s*' ..
'\d\+ CONCAT\_s*' ..
'\d\+ STORE $0\_s*' ..
'endfor\_s*' ..
--- 1254,1260
'res ..= str\_s*' ..
'\d\+ LOAD $0\_s*' ..
'\d\+ LOAD $2\_s*' ..
! '\d 2STRING_ANY stack\[-1\]\_s*' ..
'\d\+ CONCAT\_s*' ..
'\d\+ STORE $0\_s*' ..
'endfor\_s*' ..
*** ../vim-8.2.3262/src/version.c 2021-07-31 22:17:25.045867805 +0200
--- src/version.c 2021-07-31 22:50:36.446819489 +0200
***
*** 757,758
--- 757,760
{ /* Add new patch number below this line */
+ /**/
+ 3263,
/**/
--
You cannot propel yourself forward by patting yourself on the back.
/// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\help me help AIDS victims -- http://ICCF-Holland.org///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202107312051.16VKpZ7T086188%40masaka.moolenaar.net.