develooper Front page | perl.perl5.porters | Postings from June 2016

[perl #127333] until( assignment ) doesn't warn when while(assignment ) does

Thread Previous
From:
Dan Collins via RT
Date:
June 7, 2016 01:17
Subject:
[perl #127333] until( assignment ) doesn't warn when while(assignment ) does
Message ID:
rt-4.0.18-24614-1465262205-1477.127333-15-0@perl.org
On Wed Jan 20 17:14:21 2016, tonyc wrote:
> This is similar to #127122, but doesn't have quite as simple a fix.

You're right.

I started by looking at what you did for #127122, but the "hack" of treating an unless as an if won't work here. Ultimately, I added a few lines of code to op.c to accept this special case - the condition which currently generates the warning, but with an OP_NOT around it.

I also added a test for this bug to t/lib/warnings/op, as well as a test for the related while(assignment) case, which didn't have a test. The tests reduce to while(0) and until(1) so as to not hang the entire test suite. All tests pass for me.

Patch attached, hopefully formatted correctly.

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

Thread Previous


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