develooper Front page | perl.perl5.porters | Postings from October 2003

[perl #24250] "return" required in some anonymous closures

From:
perlbug-followup
Date:
October 19, 2003 22:26
Subject:
[perl #24250] "return" required in some anonymous closures
Message ID:
rt-24250-66224.12.2624559698575@rt.perl.org
# New Ticket Created by  martin@suttles.sca.sfbay.sun.com 
# Please include the string:  [perl #24250]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24250 >



This is a bug report for perl from martin@suttles.sca.sfbay.sun.com,
generated with the help of perlbug 1.34 running under perl v5.8.1.


-----------------------------------------------------------------
[Please enter your report here]
Consider the following perl program

my $count = 0;
my $x = [sub() { $count },
	 sub() { return $count },
	 sub($) { $count += $_[0] }];
$x->[2](3);
printf "%d %d\n", $x->[0](), $x->[1]();

This prints
0 3
when it should print
3 3

The two anonymous subs $x->[0] and $x->[1] should
have exactly the same effect because `return' is
supposed to be redundant when returning the last
expression in a sub.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl v5.8.1:

Configured by martin at Sun Oct 19 13:47:11 PDT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration:
  Platform:
    osname=solaris, osvers=2.9, archname=sun4-solaris
    uname='sunos suttles 5.9 generic_112233-05 sun4u sparc sunw,sun-blade-1000 '
    config_args='-ds -e -Dprefix=/usr/local'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef 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 ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-I/usr/local/include'
    ccversion='Sun C 5.5 2003/03/12', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    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='cc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/u/SUNWspro/prod/lib -L/usr/local/lib '
    libpth=/usr/lib /usr/ccs/lib /u/SUNWspro/prod/lib /usr/local/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -z ignore -z lazyload -z combreloc'
    cccdlflags='-KPIC', lddlflags=' -G  -z ignore -z lazyload -z combreloc -L/usr/lib -L/usr/ccs/lib -L/u/SUNWspro/prod/lib -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.1:
    /usr/local/lib/perl5/5.8.1/sun4-solaris
    /usr/local/lib/perl5/5.8.1
    /usr/local/lib/perl5/site_perl/5.8.1/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.1
    /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.8.1:
    HOME=/u/martin
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/u/martin/bin:/u/martin/bin/sun:/usr/java1.4.2/bin:/java/devtools/sparc/bin:/usr/local/bin:/usr/local/samba/bin:/usr/sfw/bin:/opt/sfw/bin:/usr/dt/bin:/usr/openwin/bin:/usr/xpg4/bin:/usr/proc/bin:/usr/ccs/bin:/usr/bin:/sbin:/usr/sbin:/java/devtools/sparc/gnucc/bin:/u/SUNWspro/bin:.
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh




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