Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.95k stars 554 forks source link

builtin attrs on subrutine declarations #7972

Closed p5pRT closed 19 years ago

p5pRT commented 19 years ago

Migrated from rt.perl.org#36297 (status was 'resolved')

Searchable as RT36297$

p5pRT commented 19 years ago

From @salva

Created by @salva

Builtin attributes are parsed but ignored on subroutine declarations\, for example​:

$ perl -e 'sub foo : lvalue ; foo = 7; sub foo : lvalue { $a }' Can't modify non-lvalue subroutine call in scalar assignment at -e line 1\, near "7;" Execution of -e aborted due to compilation errors.

The patch attached solves the problem.

Cheers\,

  - Salvador.

Perl Info ``` Flags: category=core severity=medium Site configuration information for perl v5.8.6: Configured by salva at Mon Dec 6 18:40:54 CET 2004. Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=linux, osvers=2.4.26-1-686, archname=i686-linux-thread-multi uname='linux cabo 2.4.26-1-686 #1 tue aug 24 13:46:05 jst 2004 i686 gnulinux ' config_args='-Dusethreads' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-2)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Locally applied patches: @INC for perl v5.8.6: /usr/local/lib/perl5/5.8.6/i686-linux-thread-multi /usr/local/lib/perl5/5.8.6 /usr/local/lib/perl5/site_perl/5.8.6/i686-linux-thread-multi /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl/5.8.3 /usr/local/lib/perl5/site_perl . Environment for perl v5.8.6: HOME=/home/salva LANG=en_GB LANGUAGE (unset) LC_COLLATE=es_ES LC_CTYPE=es_ES LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=~/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games PERL_BADLANG (unset) SHELL=/bin/bash __________________________________ Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html ```
p5pRT commented 19 years ago

From @salva

declare_attr-0.01-patch

p5pRT commented 19 years ago

From @rgs

Salvador "FandiXXo" (via RT) wrote​:

Builtin attributes are parsed but ignored on subroutine declarations\, for example​:

$ perl -e 'sub foo : lvalue ; foo = 7; sub foo : lvalue { $a }' Can't modify non-lvalue subroutine call in scalar assignment at -e line 1\, near "7;" Execution of -e aborted due to compilation errors.

The patch attached solves the problem.

Thanks\, applied as #24851 to bleadperl.

p5pRT commented 19 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 19 years ago

@rgs - Status changed from 'open' to 'resolved'

p5pRT commented 19 years ago

From @salva

just another small patch for a related bug​: subs with builtin attributes shouldn't become constant subs\, for instance​:

$ ./perl -e 'sub foo () : assertion { 7 } ; use assertions "1"; print foo; use assertions "0"; print foo' 77

Inline Patch ```diff --- ../perl-current/op.c 2005-06-15 16:08:47.000000000 +0100 +++ op.c 2005-06-15 15:30:58.000000000 +0100 @@ -4295,7 +4295,7 @@ } #endif - if (!block || !ps || *ps || attrs) + if (!block || !ps || *ps || attrs || (CvFLAGS(PL_compcv) & ```

CVf_BUILTIN_ATTRS))   const_sv = Nullsv;   else   const_sv = op_const_sv(block\, Nullcv);

--- Rafael Garcia-Suarez via RT \perlbug\-followup@​perl\.org wrote​:

Salvador "FandiXXo" (via RT) wrote​:

Builtin attributes are parsed but ignored on subroutine declarations\, for example​:

$ perl -e 'sub foo : lvalue ; foo = 7; sub foo : lvalue { $a }' Can't modify non-lvalue subroutine call in scalar assignment at -e line 1\, near "7;" Execution of -e aborted due to compilation errors.

The patch attached solves the problem.

Thanks\, applied as #24851 to bleadperl.

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http​://mail.yahoo.com

p5pRT commented 19 years ago

From @rgs

Salvador "FandiXo" wrote​:

just another small patch for a related bug​: subs with builtin attributes shouldn't become constant subs\, for instance​:

Thanks\, applied as change #24865 to bleadperl.

$ ./perl -e 'sub foo () : assertion { 7 } ; use assertions "1"; print foo; use assertions "0"; print foo'