Re: Patch 8.2.3263

2021-07-31 Fir de Conversatie John Marriott


On 01-Aug-2021 06:51, Bram Moolenaar wrote:

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


After this patch mingw64 (gcc 11.2.0) spits out this warning:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD vim9compile.c -o 
gobjnative/vim9compile.o

vim9compile.c: In function 'compile_assignment':
vim9compile.c:7114:21: warning: 'stacktype' may be used uninitialized in 
this function [-Wmaybe-uninitialized]

 7114 | if (generate_add_instr(cctx,
  | ^~~~
 7115 | operator_type(lhs.lhs_member_type, stacktype),
  | ~~
 7116 |    lhs.lhs_member_type, 
stacktype) == FAIL)

  | ~~~


The attached patch tries to fix it.

Cheers
John

--
--
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/85052b90-939f-50fd-1521-a2bfc0df138a%40internode.on.net.
--- vim9compile.c.orig  2021-08-01 07:03:21.539288100 +1000
+++ vim9compile.c   2021-08-01 07:13:50.975729000 +1000
@@ -7083,7 +7083,7 @@
if (oplen > 0 && *op != '=')
{
type_T  *expected;
-   type_T  *stacktype;
+   type_T  *stacktype = NULL;
 
if (*op == '.')
{


Patch 8.2.3263

2021-07-31 Fir de Conversatie Bram Moolenaar


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.