On 14-Jan-2023 04:37, Bram Moolenaar wrote:
Patch 9.0.1192
Problem: No error when class function argument shadows a member.
Solution: Check for shadowing.
Files: src/vim9class.c, src/testdir/test_vim9_class.vim
After this patch, msys64 (clang 15.0.5) gives this warning:
<snip>
clang -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
-pipe -Wall -O3 -fomit-frame-pointer -fpie -fPIE -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD vim9class.c -o gobjx86-64/vim9class.o
vim9class.c:720:39: warning: comparison between pointer and integer
('int' and 'void *') [-Wpointer-integer-compare]
if (STRNCMP(uf->uf_name, "new", 3) == NULL &&
il == 2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~
1 warning generated.
</snip>
The attached patch tries to fix it. I hope I have the logic the right
way around. 😁
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/913b5df1-1023-da52-3f93-b5b28a698581%40internode.on.net.
--- vim9class.c.orig 2023-01-14 05:30:05.371749200 +1100
+++ vim9class.c 2023-01-14 05:36:04.203555800 +1100
@@ -717,7 +717,7 @@
{
// For a "new()" function "this.member" arguments are
// OK. TODO: check for the "this." prefix.
- if (STRNCMP(uf->uf_name, "new", 3) == NULL && il == 2)
+ if (STRNCMP(uf->uf_name, "new", 3) == 0 && il == 2)
continue;
garray_T *mgap = il == 1 ? &classmembers : &objmembers;
for (int mi = 0; mi < mgap->ga_len; ++mi)