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

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

Jos Boumans
October 5, 2003 15:58
[perl #24118] attribute bug on 'our' in Attribute::Handlers
Message ID:
# New Ticket Created by  Jos Boumans 
# Please include the string:  [perl #24118]
# in the subject line of all future correspondence about this issue. 
# <URL: >

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 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'

	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:
    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
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-pipe -fno-common -no-cpp-precomp
    cppflags='-no-cpp-precomp -pipe -fno-common -no-cpp-precomp
    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',
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -flat_namespace'
    libs=-lm -lc
    perllibs=-lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -flat_namespace -bundle -undefined

Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under darwin
  Compiled at Sep 24 2003 21:31:57
    . Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About