Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I get a warning for FL2 Scalar value @row[FL2] better written as $row[FL2] (ignoring that its a constant _list_)
$ ./Porting/bisect.pl --target=miniperl --start=v5.16.3 --end=v5.26.0 +--expect-fail -e 'use warnings FATAL=>"all"; sub X () {2,3}; my @a=(" +a".."z"); print @a[X]' ... commit 429a25554a608b64c0ee46c1ffe19bab3718a3c8 Author: Father Chrysostomos <sprout@cpan.org> Date: Sat Sep 14 17:23:11 2013 -0700 Reduce false positives for @hsh{$s} and @ary[$s] warnings This resolves tickets #28380 and #114024. Commit 95a31aad5 did something similar to this for the new %hash{. +..} syntax. This commit extends it to @ slices and combines the two code paths. The heuristics in toke.c can easily produce false positives. So t +he op is flagged as being a candidate for the warning. Then when op. +c has the op tree available, it examines it to see whether the heuri +stic may have been a false positive. This avoids bugs with qw "foo bar baz" and sub calls triggering the warning. The source code is no longer available for the warning, so we reco +n- struct it from the op tree, skipping the subscript if it is anythi +ng other than a const op. This means that @hash{$foo} comes out as @hash{...} and @hash{foo} + as @hash{"foo"}. It also meeans that @hash{"]"} is displayed correct +ly instead of as @hash{"]. Commit 95a31aad5 also modified the heuristic for %hash{...} to exe +mpt qw altogether. But it did not exempt it if it was preceded by a t +ab. So this commit rectifies that. This commit also improves the false positive detection by exemptin +g any ops returning lists that can get past toke.c’s heuristic. I w +ent through the entire list of ops, but I may have missed some. Also, @ slices on the lhs of = are exempt, as they change the cont +ext and are hence actually useful. $ git tag --contains 429a25554a608b6 ... v5.20.0 ...
Deparsing the code shows that FL and FL2 are called as functions @a[FL()] = @row[FL2()];
$ ./Porting/bisect.pl --start=v5.16.3 --end=v5.26.0 -e '`$^X -Ilib -MO +=Deparse -e "use constant X=>3,4; \@x[X]"`=~/\@x\[3, 4\]/ and die' ... commit f815dc14d7c5540dfb5d02d001e0101c6266f281 Author: Father Chrysostomos <sprout@cpan.org> Date: Sun Jun 30 00:20:33 2013 -0700 Inline list constants These are inlined the same way as 1..5. We have two ops: rv2av | `-- const The const op returns an AV, which is stored in the op tree, and th +en rv2av flattens it. $ git tag --contains f815dc14d7c5540d ... v5.20.0 ... # *Update:* making sure it's not just the Deparse output that changed. +.. $ ./Porting/bisect.pl --start=v5.19.0 --end=v5.21.0 -e '`$^X -Ilib -MO +=Concise -e "use constant X=>3,4; \@x[X]"`=~/entersub/ or die' ... commit f815dc14d7c5540dfb5d02d001e0101c6266f281

In reply to Re: Constants lists in array slices by haukex
in thread Constants lists in array slices by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found