-
Notifications
You must be signed in to change notification settings - Fork 584
Perl optimizes // away incorrectly #7209
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
Comments
From [email protected]Created by [email protected]Perl seems to be optimizing away // at compile time as if it were ||. A few $ perl -e 'print 0 // 2' $ perl -e 'use constant FOO => ""; print FOO // 2' $ perl -MO=Deparse -e 'print 0 // 2' Perl Info
|
From [email protected]On Wed, Mar 31, 2004 at 08:58:34PM +0000 perl@jagerman.com (via RT) wrote:
That seems to be the right thing to do. After all, // is just like || Tassilo |
The RT System itself - Status changed from 'new' to 'open' |
From @mhxOn 2004-04-01, at 08:02:09 +0200, Tassilo von Parseval wrote:
But then it shouldn't nuke 0, or should it? $ perl -e 'print 0 // 2' Marcus -- Operators killed by year 2000 bug bite. |
From [email protected]On Thu, Apr 01, 2004 at 08:08:31AM +0200 Marcus Holland-Moritz wrote:
Eh, right, sorry! My mind apparently isn't working until I have finished I withdraw in shame... Tassilo |
From @mhxOn 2004-03-31, at 20:58:34 -0000, perl@jagerman.com (via RT) wrote:
Thanks a lot for your report. I can confirm that this bug is still present in the latest The attached patch (applied to bleadperl as change #22625) Marcus |
From @mhxdor.diff--- op.c.orig 2004-04-01 07:08:56.000000000 +0200
+++ op.c 2004-04-01 07:25:25.000000000 +0200
@@ -3368,7 +3368,9 @@
no_bareword_allowed(first);
else if (ckWARN(WARN_BAREWORD) && (first->op_private & OPpCONST_BARE))
Perl_warner(aTHX_ packWARN(WARN_BAREWORD), "Bareword found in conditional");
- if ((type == OP_AND) == (SvTRUE(((SVOP*)first)->op_sv))) {
+ if ((type == OP_AND && SvTRUE(((SVOP*)first)->op_sv)) ||
+ (type == OP_OR && !SvTRUE(((SVOP*)first)->op_sv)) ||
+ (type == OP_DOR && !SvOK(((SVOP*)first)->op_sv))) {
op_free(first);
*firstp = Nullop;
other->op_private |= OPpCONST_SHORTCIRCUIT;
--- t/op/dor.t.orig 2004-04-01 07:09:41.000000000 +0200
+++ t/op/dor.t 2004-04-01 07:58:21.000000000 +0200
@@ -10,7 +10,7 @@
package main;
require './test.pl';
-plan( tests => 30 );
+plan( tests => 33 );
my($x);
@@ -72,3 +72,9 @@
is( $@, '' );
eval q# sub { print $fh /2 } #;
like( $@, qr/^Search pattern not terminated/ );
+
+# [perl #28123] Perl optimizes // away incorrectly
+
+is(0 // 2, 0, ' // : left-hand operand not optimized away');
+is('' // 2, '', ' // : left-hand operand not optimized away');
+is(undef // 2, 2, ' // : left-hand operand optimized away');
|
@iabyn - Status changed from 'open' to 'resolved' |
From @TuxOn Thu 01 Apr 2004 08:22, Marcus Holland-Moritz <mhx-perl@gmx.net> wrote:
Thanks, that change now also included in the dor-patch for 5.8.x $CPAN/authors/id/H/HM/HMBRAND/dor@22645.diff Enjoy, Have FUN!
-- |
Migrated from rt.perl.org#28123 (status was 'resolved')
Searchable as RT28123$
The text was updated successfully, but these errors were encountered: