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
Wrong warning in hash slices with qw"" #7219
Comments
From 1@c07.deThis is a bug report for perl from 1@c07.de, perl -we 'my %h; @h{qw"a b c"}= 1..3; print for keys %h' prints Scalar value @h{qw"a b c"} better written as $h{qw"a b c"} at -e line 1. Similar with other uncommon delimiters for qw: Flags: Site configuration information for perl v5.8.0: Configured by root at Sun Jul 27 08:17:01 CEST 2003. Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Locally applied patches: @INC for perl v5.8.0: Environment for perl v5.8.0: PATH=.:/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3:/opt/Acrobat5:/usr/X11R6/bin:/opt/sun-jdk-1.4.2.01/bin:/opt/sun-jdk-1.4.2.01/jre/bin:/opt/sun-jdk-1.4.2.01/jre/javaws:/usr/qt/3/bin:/usr/kde/3.1/bin |
From @mhxOn 2004-04-08, at 19:47:49 -0000, Andreas Schneider (via RT) wrote:
And this doesn't warn, even though it should: perl -we 'my %h; @h{"a,b,c"}= 1..3' I've looked at the code that triggers the warning, and it's Marcus
-- |
The RT System itself - Status changed from 'new' to 'open' |
From @davidnicolBogus warning with strawberry 5.8.9, when making a list using Whatever identifies scalar values and generates the warning is simply C:\thing>perl -wce "eval {@X{qw(abc def ghi)} = @{[1..99]}[37,22,1]}" C:\thing>perl -wce "eval {@X{qw'abc def ghi'} = @{[1..99]}[37,22,1]}" C:\thing>perl -wle "eval {@X{qw'abc def ghi'} = @{[1..99]}[37,22,1]}; |
From @tonycozOn Thu, Apr 29, 2010 at 01:20:13PM -0700, David Nicol wrote:
The problem isn't qw specifically, other constructions can cause the perl -wce 'sub foo() { qw/abc def ghi/ } @X{+foo} = ( 1 .. 3 );' perl -we '$_ = "abc"; @X{split ""} = ( 1 .. 3 );' And other characters can be used with qw: perl -we '@X{qw$abc def ghi$} = ( 1 .. 3 )' The code that produces the warning uses a fairly simple heuristic to I don't really see a way to fix this without moving it up to checking Tony |
The RT System itself - Status changed from 'new' to 'open' |
From doabackflip@gmail.comCreated by doabackflip@gmail.comI'm trying to use hash slices, but I get a warning saying Scalar value @foo{qw#a b#} better written as $foo{qw#a b#} at -e line 1. - this seems incorrect This works OK: geedorah:/home/wstest# perl -E '$foo{a}=1; $foo{b}=2; say join",", @foo{qw#a b#}' But with warnings: geedorah:/home/wstest# perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw#a b#}' But if I take perl's advice, it (unsurprisingly) doesn't work: geedorah:/home/wstest# perl -wE '$foo{a}=1; $foo{b}=2; say join",", $foo{qw#a b#}' Not using "qw" seems OK: geedorah:/home/wstest# perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{"a","b"}' From http://www.perlmonks.org/?node_id=901368 I also confirmed the warning message (I'm on v5.12.2). $ perl -wE '$foo{a}=1; $foo{b}=2; say join",", @foo{qw{a b}}' Perl Info
|
From @ikegamiCreated by @ikegami$ perl -c -we'my %f; my @a = @f{qw( a b )}' $ perl -c -we'my %f; my @a = @f{qw! a b !}' $ perl -c -we'my %f; my @a = @f{qw# a b #}' $ perl -c -we'my %f; my @a = @f{qw$ a b $}' Bug present in all versions tested: v5.8.9, v5.10.1, v5.12.2, v5.13.10. Perl Info
|
From alex-perlbug@earth.liThere's all manner of fun one can have here, this warns on the perfectly the perldev/perl% ./miniperl -w -e 'my %f; my @s = @f{"}", "a"}' the perldev/perl% ./miniperl -w -e 'my %f; my @s = @f{"]", "a"}' I've attached a patch for a failing test as I can't solve this quickly. The offensive code is from toke.c which just looks to the first closing /* Warn about @ where they meant $. */ |
From alex-perlbug@earth.lidiff --git a/t/lib/warnings/toke b/t/lib/warnings/toke |
The RT System itself - Status changed from 'new' to 'open' |
From alex-perlbug@earth.liExcept, of course, I meant to send you this test patch. Sorry. Alex On Sat Apr 30 22:52:59 2011, quidity wrote:
|
From alex-perlbug@earth.lidiff --git a/t/lib/warnings/toke b/t/lib/warnings/toke |
From alex-perlbug@earth.liNo, I didn't. Warnings first, done last. As you were. The first patch On Sat Apr 30 22:57:59 2011, quidity wrote:
|
From ailin@flupps.netCreated by ailin@flupps.netThe following code perl -Mwarnings -E"@x{qw'y z'}" elicits the warning Scalar value @x{qw'y z'} better written as $x{qw'y z'} at -e line 1. which is clearly bogus and following the recommendation would break The issue has been confirmed on freenode #perl channel. Perl Info
|
From @cpansproutFixed in 429a255. -- Father Chrysostomos |
From [Unknown Contact. See original ticket]Fixed in 429a255. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#28380 (status was 'resolved')
Searchable as RT28380$
The text was updated successfully, but these errors were encountered: