develooper Front page | perl.perl5.porters | Postings from May 2010

[perl #75288] B::Deparse changes 1 == 1 to 1 in when

Thread Next
From:
brian d foy
Date:
May 25, 2010 02:08
Subject:
[perl #75288] B::Deparse changes 1 == 1 to 1 in when
Message ID:
rt-3.6.HEAD-4976-1274598250-535.75288-75-0@perl.org
# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #75288]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75288 >


Subject: B::Deparse changes 1 == 1 to 1 in when
Message-Id: <5.10.1_22130_1274593148@macpro.local>
Reply-To: brian@mac-pro.local
To: perlbug@perl.org


This is a bug report for perl from brian@mac-pro.local,
generated with the help of perlbug 1.39 running under perl 5.10.1.


-----------------------------------------------------------------
[Please describe your issue here]

I found a case where B::Deparse does the wrong thing. In this foreach-when,
the 1 == 1 is always true and that block always runs. This is the
documented behavior, and there is an output line for every input number:

	use 5.010;
	
	my $a = 1;
	foreach( 1 .. 10 )
		{
		when( 1 == 1 ) {
			print "Always true. \$_ is $_\n";
			}
		}		

This is the result of deparsing on both 5.10.1 through 5.13.1. The 1 == 1 comes
back as just 1, so now a smart match takes place. Only the first input
number triggers the when():

	sub BEGIN {
		require 5.01;
	}
	BEGIN {
		$^H{'feature_say'} = q(1);
		$^H{'feature_state'} = q(1);
		$^H{'feature_switch'} = q(1);
	}
	my $a = 1;
	foreach $_ (1 .. 10) {
		when (1) {
			print "Always true. \$_ is $_\n";
		}
	}



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=library
    severity=low
    module=B::Deparse
---
Site configuration information for perl 5.10.1:

Configured by brian at Sat Dec  5 14:57:53 CST 2009.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

  Platform:
    osname=darwin, osvers=10.2.0, archname=darwin-2level
    uname='darwin mac-pro.local 10.2.0 darwin kernel version 10.2.0:
tue nov 3 23:08:29 pst 2009; root:xnu-1486.2.11~3release_i386 i386
i386 '
    config_args='-des -Dprefix=/usr/local/perls/perl-5.10.1'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -fstack-protector',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector'
    libpth=/usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.10.1:
    /usr/local/perls/perl-5.10.1/lib/5.10.1/darwin-2level
    /usr/local/perls/perl-5.10.1/lib/5.10.1
    /usr/local/perls/perl-5.10.1/lib/site_perl/5.10.1/darwin-2level
    /usr/local/perls/perl-5.10.1/lib/site_perl/5.10.1
    .

---
Environment for perl 5.10.1:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/brian
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=C
    LC_COLLATE=en_US.utf-8
    LC_CTYPE=en_US.utf-8
    LC_MESSAGES=en_US.utf-8
    LC_MONETARY=en_US.utf-8
    LC_NUMERIC=en_US.utf-8
    LC_TIME=en_US.utf-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/brian/bin:/usr/local/bin:/opt/local/bin:/Users/brian/TPR/scripts:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/mysql/bin:/usr/X11R6/bin:/usr/local/teTeX/bin/powerpc-apple-darwin-current:/usr/local/pgsql/bin:/usr/local/gcj/bin:/Library/Frameworks/Python.framework/Versions/Current/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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