Skip Menu |
Report information
Id: 69050
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: comdog <brian.d.foy [at] gmail.com>
nicholas <nick [at] ccl4.org>
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: low
Type: core
Perl Version: 5.11.0
Fixed In: (no value)

Attachments
0002-add-OP_USE-to-distinguish-use-from-BEGIN-require.patch



Subject: BEGIN {require 5.011} imports features
Date: Tue, 08 Sep 2009 11:10:38 +0100
To: perlbug [...] perl.org
From: Nicholas Clark <nick [...] etla.org>
Download (untitled) / with headers
text/plain 3.8k
This is a bug report for perl from nick@ccl4.org, generated with the help of perlbug 1.39 running under perl 5.11.0. ----------------------------------------------------------------- [Please describe your issue here] It is documented that C<use 5.011;> (etc) implicitly use feature. Hence $ ./perl -Ilib -e 'say "Hi"' String found where operator expected at -e line 1, near "say "Hi"" (Do you need to predeclare say?) syntax error at -e line 1, near "say "Hi"" Execution of -e aborted due to compilation errors. $ ./perl -Ilib -e 'use 5.011; say "Hi"' Hi However, it is not documented that C<require 5.011> does this. Hence this is a bug: $ ./perl -Ilib -e 'BEGIN {require 5.011}; say "Hi"' Hi That should fail with the "String found" error. (Zefram spotted this) Nicholas Clark [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=low --- Site configuration information for perl 5.11.0: Configured by nick at Mon Sep 7 22:49:10 BST 2009. Summary of my perl5 (revision 5 version 11 subversion 0) configuration: Commit id: 380d1e906b715974eb33a0beaa622ee519b3b0e0 Platform: osname=linux, osvers=2.6.18-xenu, archname=x86_64-linux uname='linux zazen 2.6.18-xenu #1 smp thu oct 4 12:23:41 bst 2007 x86_64 gnulinux ' config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list= -Dinc_version_list_init=0 -Doptimize=-g -Uusethreads -Uuse64bitall -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9 -Uusevendorprefix -Uvendorprefix=~/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9 -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -de' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='ccache gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-g', cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.3.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.7' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.11.0: lib /home/nick/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9/lib/perl5/site_perl/5.11.0/x86_64-linux /home/nick/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9/lib/perl5/site_perl/5.11.0 /home/nick/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9/lib/perl5/5.11.0/x86_64-linux /home/nick/Sandpit/snap5.9.x-GitLive-blead-2173-g380d1e9/lib/perl5/5.11.0 . --- Environment for perl 5.11.0: HOME=/home/nick LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin PERL_BADLANG (unset) SHELL=/bin/bash
Subject: [PATCH] RE: [perl #69050] BEGIN {require 5.011} imports features
Date: Fri, 11 Sep 2009 16:11:20 +0100
To: <perl5-porters [...] perl.org>, <bugs-bitbucket [...] netlabs.develooper.com>
From: "Robin Barker" <Robin.Barker [...] npl.co.uk>
Download (untitled) / with headers
text/plain 493b
Show quoted text
> However, it is not documented that C<require 5.011> does this. > Hence this is a bug: > > $ ./perl -Ilib -e 'BEGIN {require 5.011}; say "Hi"' > Hi > > That should fail with the "String found" error.
I have fixed this by introducing a separate opcode for use, OP_USE, used in pp_require to distinguish use from require. There are lots of collateral changes and this may not be the right approach. In particular, Safe.pm will not work as before wrt to require/use Robin

Message body is not shown because sender requested not to inline it.

CC: perl5-porters [...] perl.org
Subject: Re: [PATCH] RE: [perl #69050] BEGIN {require 5.011} imports features
Date: Fri, 11 Sep 2009 11:20:59 -0500
To: Robin Barker <Robin.Barker [...] npl.co.uk>
From: David Nicol <davidnicol [...] gmail.com>
Download (untitled) / with headers
text/plain 567b
On Fri, Sep 11, 2009 at 10:11 AM, Robin Barker <Robin.Barker@npl.co.uk> wrote: Show quoted text
> > I have fixed this by introducing a separate opcode for use, OP_USE, > used in pp_require to distinguish use from require. > > There are lots of collateral changes and this may not be the right > approach. > > In particular, Safe.pm will not work as before wrt to require/use > > Robin
Does this mean that use MyMagicTieingModule my $VariableIntendedToBeVisibileInThisScope; will start DWIW? -- "As if you could kill time without injuring eternity!" -- Henry David Thoreau
CC: bugs-bitbucket [...] netlabs.develooper.com
Subject: Re: [PATCH] RE: [perl #69050] BEGIN {require 5.011} imports features
Date: Fri, 11 Sep 2009 20:05:18 +0100
To: perl5-porters [...] perl.org
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 508b
Robin Barker wrote: Show quoted text
>There are lots of collateral changes and this may not be the right >approach.
I think a better approach is: * "require 5.010" ceases to do anything other than the version check * "use 5.010" expands (in the optree) to something like BEGIN { require 5.010; require feature; feature->import(":5.010"); } (where previously it only expanded to "BEGIN { require 5.010 }") That is, the feature magic goes into the parsing of the "use" instruction, not into execution. -zefram
Subject: BEGIN { require VERSION } loads feature.pm
Date: Sat, 3 Jul 2010 18:50:35 -0500
To: perlbug [...] perl.org
From: brian d foy <brian.d.foy [...] gmail.com>
Download (untitled) / with headers
text/plain 3.5k
This is a bug report for perl from brian@mimibean.local, generated with the help of perlbug 1.39 running under perl 5.12.1. ----------------------------------------------------------------- [Please describe your issue here] The feature.pm docs notes that it's implicitly loaded by -E or use VERSION. However, it's also implicitly loaded by BEGIN { require VERSION } It is not loaded with just a plain require though: require VERSION; What's the right behavior? I don't expect require ever to do an implicit import of anything. If I know what its supposed to do, I can update the use, require, and feature docs. [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
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Tue, 6 Jul 2010 00:48:14 -0400
To: perl5-porters [...] perl.org
From: David Golden <xdaveg [...] gmail.com>
Download (untitled) / with headers
text/plain 789b
Show quoted text
> The feature.pm docs notes that it's implicitly loaded by -E > or use VERSION. However, it's also implicitly loaded by > >     BEGIN { require VERSION } > > It is not loaded with just a plain require though: > >        require VERSION; > > What's the right behavior?
That's a tricky question. Since "use VERSION" is effectively equivalent to "BEGIN { require VERSION }", they have the same behavior. On the other hand, I also generally expect "require" to have no import-like action. The relevant "if" clause in pp_ctl.c is this: if (PL_compcv && !(cUNOP->op_first->op_private & OPpCONST_NOVER)) { I don't know know enough of the guts to know how to differentiate between use and BEGIN+require, but if someone does, then I think the change is appropriate to make. -- David
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Tue, 6 Jul 2010 12:59:15 -0500
To: perlbug-followup [...] perl.org
From: brian d foy <brian.d.foy [...] gmail.com>
Download (untitled) / with headers
text/plain 778b
On Tue, Jul 6, 2010 at 5:01 AM, David Golden via RT <perlbug-followup@perl.org> wrote: Show quoted text
>> The feature.pm docs notes that it's implicitly loaded by -E >> or use VERSION. However, it's also implicitly loaded by >> >>     BEGIN { require VERSION } >> >> It is not loaded with just a plain require though: >> >>        require VERSION; >> >> What's the right behavior?
> > That's a tricky question.  Since "use VERSION" is effectively > equivalent to "BEGIN { require VERSION }",
It may be effectively the same (meaning that's what actually happens), but it's not what anyone should expect given that use is explicitly documented as separate require and import steps when you use it with a module name. -- brian d foy <brian.d.foy@gmail.com> http://www.pair.com/~comdog/
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Tue, 6 Jul 2010 19:35:19 +0100
To: brian.d.foy [...] gmail.com, perl5-porters [...] perl.org
From: Ben Morrow <ben [...] morrow.me.uk>
Quoth brian.d.foy@gmail.com (brian d foy): Show quoted text
> On Tue, Jul 6, 2010 at 5:01 AM, David Golden via RT > <perlbug-followup@perl.org> wrote:
> >> The feature.pm docs notes that it's implicitly loaded by -E > >> or use VERSION. However, it's also implicitly loaded by > >> > >> � � BEGIN { require VERSION } > >> > >> It is not loaded with just a plain require though: > >> > >> � � � �require VERSION; > >> > >> What's the right behavior?
> > > > That's a tricky question. �Since "use VERSION" is effectively > > equivalent to "BEGIN { require VERSION }",
> > It may be effectively the same (meaning that's what actually happens), > but it's not what anyone should expect given that use is explicitly > documented as separate require and import steps when you use it with a > module name.
I quite like the idea of BEGIN { require VERSION } being a side-effect- free way of requesting a version. I would also quite like use 5.12 (); to do the same thing, though I don't know if the parser can handle that. Ben
CC: brian.d.foy [...] gmail.com, perl5-porters [...] perl.org
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Tue, 6 Jul 2010 16:31:36 -0400
To: Ben Morrow <ben [...] morrow.me.uk>
From: David Golden <xdaveg [...] gmail.com>
Download (untitled) / with headers
text/plain 877b
On Tue, Jul 6, 2010 at 2:35 PM, Ben Morrow <ben@morrow.me.uk> wrote: Show quoted text
> I quite like the idea of BEGIN { require VERSION } being a side-effect- > free way of requesting a version. I would also quite like > >    use 5.12 (); > > to do the same thing, though I don't know if the parser can handle that.
Not easily. It's trivial to make toke.c take it, but the way features/strict are implemented, the action is in pp_require which doesn't know about the import list. The right thing to do is to move feature/strict enablement to be a separate action after the require operation the same way that a regular import method call is set up by Perl_utilize. That should also fix the BEGIN { require VERSION } issue that brian points out. It's beyond my own skill to do quickly, but I encourage others to take up the challenge if they have the round tuits for it. :-) -- David
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Wed, 7 Jul 2010 07:06:27 +0000 (GMT)
To: perl5 porters <perl5-porters [...] perl.org>
From: Robin Barker <r.m.barker [...] btinternet.com>
Download (untitled) / with headers
text/plain 184b
This was discussed here as "perl version checks" on 8 Septermber 2009. I had a patch that involved separate tokens for "require" and "use", but it was not used (or required) :) Robin
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Thu, 8 Jul 2010 10:51:15 +0100
To: perl5 porters <perl5-porters [...] perl.org>
From: Zefram <zefram [...] fysh.org>
Download (untitled) / with headers
text/plain 406b
Robin Barker wrote: Show quoted text
>I had a patch that involved separate tokens for "require" and "use",
I think that would be a bad idea. Instead, the special casing that's currently in pp_require should move into the compilation of "use". So use 5.012; should compile as BEGIN { require 5.012; require feature; "feature"->import(":5.012"); } with "require 5.012" doing only the version check. -zefram
CC: perl5 porters <perl5-porters [...] perl.org>
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Thu, 8 Jul 2010 12:35:37 +0200
To: Zefram <zefram [...] fysh.org>
From: demerphq <demerphq [...] gmail.com>
Download (untitled) / with headers
text/plain 638b
On 8 July 2010 11:51, Zefram <zefram@fysh.org> wrote: Show quoted text
> Robin Barker wrote:
>>I had a patch that involved separate tokens for "require" and "use",
> > I think that would be a bad idea.  Instead, the special casing that's > currently in pp_require should move into the compilation of "use".  So > >        use 5.012; > > should compile as > >        BEGIN { >                require 5.012; >                require feature; >                "feature"->import(":5.012"); >        } > > with "require 5.012" doing only the version check.
+1 yves -- perl -Mre=debug -e "/just|another|perl|hacker/"
CC: perl5 porters <perl5-porters [...] perl.org>
Subject: Re: [perl #76374] BEGIN { require VERSION } loads feature.pm
Date: Thu, 8 Jul 2010 12:44:53 +0200
To: Zefram <zefram [...] fysh.org>
From: Frank Wiegand <frank.wiegand [...] gmail.com>
Download (untitled) / with headers
text/plain 560b
2010/7/8 Zefram <zefram@fysh.org>: Show quoted text
>        use 5.012; > > should compile as > >        BEGIN { >                require 5.012; >                require feature; >                "feature"->import(":5.012"); >        } > > with "require 5.012" doing only the version check.
Great! But feature.pm bundles are like ':5.12'. So it should be        BEGIN {                require 5.012;                require feature;                "feature"->import(":5.12");        } Thanks, Frank
Fixed by 88e9444.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org