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

[perl #24118] attribute bug on 'our' in Attribute::Handlers

From:
Jos Boumans
Date:
October 5, 2003 15:58
Subject:
[perl #24118] attribute bug on 'our' in Attribute::Handlers
Message ID:
rt-24118-65651.4.52270614895454@rt.perl.org
# New Ticket Created by  Jos Boumans 
# Please include the string:  [perl #24118]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24118 >


when running the following code:

my $bar  : watch = 1;
our $zot : watch = 1;

the 'my' variable will correctly take the attribute, but the 'our' will
not and give the following error:
	Invalid SCALAR attribute: watch at x.pl line 7

A quick debug run shows that it breaks due to some @ISA oddness:
 	# OK:
	perl -MAttribute::Handlers -e'sub a:ATTR(SCALAR){1};our$x:a'
	perl -MAttribute::Handlers -e'@ISA='b';sub b::a:ATTR(SCALAR);my$x:a'

	# BREAKS:
	perl -MAttribute::Handlers -e'@ISA='b';sub b::a:ATTR(SCALAR);our$x:a'
		Invalid SCALAR attribute: a at -e line 1
		BEGIN failed--compilation aborted at -e line 1.

This bug exist at least in Attribute::Handlers v0.77 and perl 5.8.0
Find my perl -V below.

There's another issue involving attributes:
	perl -e'$x:unique=1'
		syntax error at -e line 1, near "$x:"
		Execution of -e aborted due to compilation errors.
	perl -e'our $x:unique=1'
	perl -e'my $x:unique=1'

But 'perldoc attributes' tells me:
	For global variables there is "unique" attribute: see
       "our" in perlfunc.

So i'm not quite expecting it to be a syntax error... (may just be a
documentation bug though)

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=darwin, osvers=6.8, archname=darwin
    uname='darwin beheer-ibook 6.8 darwin kernel version 6.8: wed sep 10
15:20:55 pdt 2003; root:xnuxnu-344.49.obj~2release_ppc power macintosh
powerpc '
    config_args='-Dprefix=/opt -des'
    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 ='-pipe -fno-common -no-cpp-precomp
-fno-strict-aliasing',
    optimize='-O3',
    cppflags='-no-cpp-precomp -pipe -fno-common -no-cpp-precomp
-fno-strict-aliasing'
    ccversion='', gccversion='3.1 20020420 (prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -flat_namespace'
    libpth=/usr/lib
    libs=-lm -lc
    perllibs=-lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,
libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -flat_namespace -bundle -undefined
suppress'


Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under darwin
  Compiled at Sep 24 2003 21:31:57
  %ENV:
    PERL5LIB="/sw/lib/perl5"
  @INC:
    /sw/lib/perl5/darwin
    /sw/lib/perl5
    /opt/lib/perl5/5.8.0/darwin
    /opt/lib/perl5/5.8.0
    /opt/lib/perl5/site_perl/5.8.0/darwin
    /opt/lib/perl5/site_perl/5.8.0
    /opt/lib/perl5/site_perl
    .




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