develooper Front page | perl.perl5.porters | Postings from December 2017

[perl #132645] Array names starting with 'Inf' can be poorlybehaved.

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
December 22, 2017 21:44
Subject:
[perl #132645] Array names starting with 'Inf' can be poorlybehaved.
Message ID:
rt-4.0.24-31367-1513979075-317.132645-15-0@perl.org
On Fri, 22 Dec 2017 13:40:33 -0800, sprout wrote:
> On Fri, 22 Dec 2017 09:41:56 -0800, public@khwilliamson.com wrote:
> > I am posting this for Dan Book, who is having trouble getting email
> > to
> > perlbug through.
> >
> > The build options and version of perl is immaterial here, except
> > since 5.22.
> >
> > When the warning "Scalar value @arrayname[0] better written as
> > $arrayname[0]"
> > is triggered (any time an array slice is used with only one element),
> > this results
> > in an error if the array's name starts with 'inf'. Code to reproduce:
> >
> > use warnings;
> > my @infasdf;
> > my @x = @infasdf[0];
> > 1
> >
> > Error from above code (since 5.22): Cannot printf Inf with 'c' at
> > (IRC)
> > line 3.
> 
> $ ../perl.git-copy/Porting/bisect.pl --target=miniperl --start=v5.20.0
> --end=v5.22.0 -- ./miniperl -Ilib /tmp/foo
> ...
> 3396ed3031889b7a6890cbcb14149feb7f1ed41f is the first bad commit
> commit 3396ed3031889b7a6890cbcb14149feb7f1ed41f
> Author: Jarkko Hietaniemi <jhi@iki.fi>
> Date:   Sun Jan 25 12:27:44 2015 -0500
> 
> infnan: Simplify inf parsing.
> 
> Accept anything beginning with /^inf/i,
> but warn if there's trailing stuff.
> 
> :100644 100644 66b08834448704597e416e7f3a024b8329245bd0
> 7819c60d94adac3f7b96b11ed816cc12d57b1a27 M      numeric.c
> :040000 040000 85a647618418ee945da09230ba2a172f26331d0c
> 5a472ae9721446be7d90ffdfe00bfb555e1c3d07 M      t
> bisect run success
> That took 1335 seconds.

That commit only changed grok_infnan.  I don‘t understand why this (from op.c:scalar_slice_warning) calls grok_infnan:

    if (key)
       /* diag_listed_as: Scalar value @%s[%s] better written as $%s[%s] */
	Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
		   "Scalar value @%" SVf "%c%s%c better written as $%" SVf
		   "%c%s%c",
		    SVfARG(name), lbrack, key, rbrack, SVfARG(name),
		    lbrack, key, rbrack);

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=132645

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About