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

[perl #77510] when() as a statement modifier outside a topicalizer both works and fails

Thread Next
From:
brian d foy
Date:
August 30, 2010 01:05
Subject:
[perl #77510] when() as a statement modifier outside a topicalizer both works and fails
Message ID:
rt-3.6.HEAD-5116-1283146198-1535.77510-75-0@perl.org
# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #77510]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77510 >


This is a bug report for perl from brian.d.foy@gmail.com,
generated with the help of perlbug 1.39 running under perl 5.12.1.


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

Perl 5.12 allows when() as a statement modifier. I think this
is only intended inside a topicalizer, but it parses just
fine outside a topicalizer.

This script compiles just fine:

	use 5.012;
	
	my %microchips = (
		  'Mimi'   => 123,
		  'Buster' => undef,
		  'Roscoe' => 345,
		);
	
	say "Known cats are @{[keys %microchips]}\n";
	{
	print "Enter a cat name> ";
	chomp( $_ = <STDIN> );
	say "Found cat with id $microchips{$_}" when %microchips;
	redo;
	}

Now, when I run this and respond to a prompt with a cat's name
that is in the hash, the say() outputs its message and Perl
dies:

	Buster
	Found cat with id
	Can't use when() outside a topicalizer at test line 11, <STDIN> line

That's fine, but I don't get the same error when I respond with
a cat's name that is not in the hash:

	Enter a cat name> Ella
	Enter a cat name> Buster
	Found cat with id
	Can't use when() outside a topicalizer at test line 12, <STDIN> line 2.

That is, the when() always works. If its condition is true, it also dies. If
its condition is false, it does not die.

I verified this with all released versions of 5.12 and 5.13.

I figure this should be a compile-time error, or, if we're really lazy, just
never die.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.12.1:

Configured by brian at Wed Jun 16 15:54:54 PDT 2010.

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

  Platform:
    osname=darwin, osvers=9.8.0, archname=darwin-2level
    uname='darwin mimibean.local 9.8.0 darwin kernel version 9.8.0:
wed jul 15 16:55:01 pdt 2009; root:xnu-1228.15.4~1release_i386 i386
i386 '
    config_args='-des -Dprefix=/usr/local/perls/perl-5.12.1'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
    ccversion='', gccversion='4.0.1 (Apple Inc. build 5490)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, 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 -L/usr/local/lib'
    libpth=/usr/local/lib /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
-L/usr/local/lib -fstack-protector'

Locally applied patches:


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

---
Environment for perl 5.12.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