Re: Patch 8.2.2002

2020-11-17 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 18-Nov-2020 04:51, Bram Moolenaar wrote:
> > Patch 8.2.2002
> > Problem:Vim9: lambda argument shadowed by function name.
> > Solution:   Let function name be shadowed by lambda argument. (closes #7313)
> > Files:  src/vim9compile.c, src/testdir/test_vim9_func.vim
> >
> >
> >
> After this patch, mingw64 (gcc 10.2) throws 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_call':
> vim9compile.c:2746:8: warning: 'ufunc' may be used uninitialized in this 
> function [-Wmaybe-uninitialized]
>   2746 | if (ufunc != NULL)
>    |    ^
> 
> 
> The attached patch tries to fix it.

Thanks!

-- 
Two fish in a tank. One says to the other:
"Do you know how to drive this thing?"

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202011171857.0AHIv1Ul1521101%40masaka.moolenaar.net.


Re: Patch 8.2.2002

2020-11-17 Fir de Conversatie John Marriott


On 18-Nov-2020 04:51, Bram Moolenaar wrote:

Patch 8.2.2002
Problem:Vim9: lambda argument shadowed by function name.
Solution:   Let function name be shadowed by lambda argument. (closes #7313)
Files:  src/vim9compile.c, src/testdir/test_vim9_func.vim




After this patch, mingw64 (gcc 10.2) throws 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_call':
vim9compile.c:2746:8: warning: 'ufunc' may be used uninitialized in this 
function [-Wmaybe-uninitialized]

 2746 | if (ufunc != NULL)
  |    ^


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/4d258aeb-2372-1651-f90c-c8f0dd4ce293%40internode.on.net.
--- vim9compile.c.orig  2020-11-18 05:09:12.243811200 +1100
+++ vim9compile.c   2020-11-18 05:22:03.131561300 +1100
@@ -2626,7 +2626,7 @@
 char_u fname_buf[FLEN_FIXED + 1];
 char_u *tofree = NULL;
 interror = FCERR_NONE;
-ufunc_T*ufunc;
+ufunc_T*ufunc = NULL;
 intres = FAIL;
 intis_autoload;
 


Patch 8.2.2002

2020-11-17 Fir de Conversatie Bram Moolenaar


Patch 8.2.2002
Problem:Vim9: lambda argument shadowed by function name.
Solution:   Let function name be shadowed by lambda argument. (closes #7313)
Files:  src/vim9compile.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.2001/src/vim9compile.c   2020-11-16 22:11:39.625599176 +0100
--- src/vim9compile.c   2020-11-17 18:44:26.340431930 +0100
***
*** 2712,2724 
goto theend;
  }
  
! // If we can find the function by name generate the right call.
! // Skip global functions here, a local funcref takes precedence.
! ufunc = find_func(name, FALSE, cctx);
! if (ufunc != NULL && !func_is_global(ufunc))
  {
!   res = generate_CALL(cctx, ufunc, argcount);
!   goto theend;
  }
  
  // If the name is a variable, load it and use PCALL.
--- 2712,2730 
goto theend;
  }
  
! // An argument or local variable can be a function reference, this
! // overrules a function name.
! if (lookup_local(namebuf, varlen, cctx) == NULL
!   && arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK)
  {
!   // If we can find the function by name generate the right call.
!   // Skip global functions here, a local funcref takes precedence.
!   ufunc = find_func(name, FALSE, cctx);
!   if (ufunc != NULL && !func_is_global(ufunc))
!   {
!   res = generate_CALL(cctx, ufunc, argcount);
!   goto theend;
!   }
  }
  
  // If the name is a variable, load it and use PCALL.
*** ../vim-8.2.2001/src/testdir/test_vim9_func.vim  2020-11-17 
18:23:15.519278866 +0100
--- src/testdir/test_vim9_func.vim  2020-11-17 18:48:00.235954228 +0100
***
*** 1456,1461 
--- 1456,1470 
CheckScriptSuccess(lines)
  enddef
  
+ def Shadowed(): list
+   var FuncList: list = [{ -> 42}]
+   return FuncList->map({_, Shadowed -> Shadowed()})
+ enddef
+ 
+ def Test_lambda_arg_shadows_func()
+   assert_equal([42], Shadowed())
+ enddef
+ 
  def Line_continuation_in_def(dir: string = ''): string
var path: string = empty(dir)
\ ? 'empty'
*** ../vim-8.2.2001/src/version.c   2020-11-17 18:23:15.519278866 +0100
--- src/version.c   2020-11-17 18:49:09.743797847 +0100
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 2002,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
265. Your reason for not staying in touch with family is that
 they do not have e-mail addresses.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\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/202011171751.0AHHpN4d1503377%40masaka.moolenaar.net.