Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl5: false warning on "Multidimensional syntax not supported" #16535

Closed
p5pRT opened this issue Apr 26, 2018 · 17 comments
Closed

perl5: false warning on "Multidimensional syntax not supported" #16535

p5pRT opened this issue Apr 26, 2018 · 17 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 26, 2018

Migrated from rt.perl.org#133155 (status was 'open')

Searchable as RT133155$

@p5pRT
Copy link
Author

p5pRT commented Apr 26, 2018

From wolf-dietrich_moeller@t-online.de

Hi,
I found a false warning on "Multidimensional syntax".
The test program below is executed correctly, but line 7
triggers a false warning. This is surprising, as the other
'print' lines have a similar structure without raising this
warning. Why should this be raised here? From the syntax it
is clear that both variables are parameters of "index", as
it has (at least) two arguments.

Best regards
Wolf

use warnings;
my @x = (['a','b']);
my @y = ('a','b');
my $z = 'rst';
my $i = 's';
print ' 6: ',$x[0][index $z,$i],"\n";
print ' 7: ',$y[index $z,$i],"\n";
print ' 8: ',$y[index($z,$i)],"\n";
print ' 9: ',$y[index 'rst',$i],"\n";
print '10: ',@y[index $z,$i],"\n";

Output:

Multidimensional syntax $y[index $z,$i] not supported at test_index.pl line
7.
6: b
7: b
8: b
9: b
10: b
Perl Info
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.26.2:

Configured by strawberry-perl at Sun Apr 15 11:47:59 2018.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration:

Platform:
osname=MSWin32
osvers=10.0.16299.371
archname=MSWin32-x86-multi-thread-64int
uname='Win32 strawberry-perl 5.26.2.1 #1 Sun Apr 15 11:47:13 2018 i386'
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
Compiler:
cc='gcc'
ccflags =' -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
optimize='-s -O2'
cppflags='-DWIN32'
ccversion=''
gccversion='7.1.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=12
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='long long'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='g++'
ldflags ='-s -L"C:\Perl\perl\lib\CORE" -L"C:\Perl\c\lib"'
libpth=C:\Perl\c\lib C:\Perl\c\i686-w64-mingw32\lib
C:\Perl\c\lib\gcc\i686-w64-mingw32\7.1.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
libc=
so=dll
useshrplib=true
libperl=libperl526.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=xs.dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-mdll -s -L"C:\Perl\perl\lib\CORE" -L"C:\Perl\c\lib"'


---
@INC for perl 5.26.2:
C:/Perl/perl/site/lib
C:/Perl/perl/vendor/lib
C:/Perl/perl/lib

---
Environment for perl 5.26.2:
HOME (unset)
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=...
PERL_BADLANG (unset)
SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented May 7, 2018

From @jkeenan

I've been able to reproduce this in perl-5.24.1. Hence, it's not a regression introduced in the 5.27 development cycle and is not a blocker for 5.28.0.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 7, 2018

The RT System itself - Status changed from 'new' to 'open'

@toddr
Copy link
Member

toddr commented Jan 31, 2020

This output seems to be consistent going back to 5.8 at the least. This sounds more like a feature request or by design.

@toddr toddr added the Closable? We might be able to close this ticket, but we need to check with the reporter label Jan 31, 2020
@hvds
Copy link
Contributor

hvds commented Jan 31, 2020

It smells like a bug to me, it is decidedly odd that the line-7 example warns when none of the other 4 examples do. If I encountered this I'd also be reporting it.

@demerphq
Copy link
Collaborator

demerphq commented Jan 31, 2020 via email

demerphq added a commit that referenced this issue Jan 31, 2020
Fix issue #16535 - $t[index $x, $y] should not throw Multidimensional
array warnings.

The heuristic for detecting lists in array subscripts is implemented
in toke.c, which means it is not particularly reliable. There are
lots of ways that code might return a list in an array subscript.

So for instance $t[do{ $x, $y }] should throw a warning but doesn't.

On the other hand, we can make this warning less likely to happen
by being a touch more careful about how we parse the inside of the
square brackets so we do not throw an exception from $t[index $x,$y].

Really this should be moved to the parser so we do not need to rely
on fallable heuristics, and also into the runtime so that if we have

    $t[f()]

and f() returns a list we can also warn there. But for now this
improves things somewhat.
@demerphq
Copy link
Collaborator

demerphq commented Jan 31, 2020 via email

@jkeenan
Copy link
Contributor

jkeenan commented Jan 31, 2020

On Fri, 31 Jan 2020 at 13:35, demerphq @.***> wrote:
[snip]
Anyway, until someone who understands the grammar much better than me steps up to move this to the parser I have pushed smoke-me/fix_issue_16535 to close this ticket. Cheers, yves
[snip]

+1

The OP's program PASS on smoke-me/fix_issue_16535 branch.

@jkeenan jkeenan removed the Closable? We might be able to close this ticket, but we need to check with the reporter label Jan 31, 2020
@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

@demerphq
Copy link
Collaborator

demerphq commented Feb 1, 2020 via email

demerphq added a commit that referenced this issue Feb 2, 2020
Fix issue #16535 - $t[index $x, $y] should not throw Multidimensional
array warnings.

The heuristic for detecting lists in array subscripts is implemented
in toke.c, which means it is not particularly reliable. There are
lots of ways that code might return a list in an array subscript.

So for instance $t[do{ $x, $y }] should throw a warning but doesn't.

On the other hand, we can make this warning less likely to happen
by being a touch more careful about how we parse the inside of the
square brackets so we do not throw an exception from $t[index $x,$y].

Really this should be moved to the parser so we do not need to rely
on fallable heuristics, and also into the runtime so that if we have

    $t[f()]

and f() returns a list we can also warn there. But for now this
improves things somewhat.
@demerphq
Copy link
Collaborator

demerphq commented Feb 2, 2020 via email

@tonycoz
Copy link
Contributor

tonycoz commented Dec 6, 2023

This was fixed by 41eecd5

@tonycoz tonycoz closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants