New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelfLoader.pm 1.0904 - Whitespace in subroutine definitions #9154
Comments
From mark.swayne@charter.netCreated by mark.swayne@charter.netI found an interesting problem with SelfLoader.pm version 1.0904 If there is any leading whitespace before a subroutine declaration, There is also no mention in the module docs that leading whitespace may Example code and the results of running it follow: ---Example code--- eval { eval { eval { eval { eval { __DATA__ sub Foo { sub Bar { sub Baz { --Example code output-- Baz Error 1: Undefined subroutine main::Baz at C:\Documents and Bar Error: Baz Error 2: Perl Info
|
From l2ot9pa02@sneakemail.comHi p5p, Mark Swayne wrote:
This problem is still present in the SelfLoader that is part of blead. Question: As with other core modules, should SelfLoader be dual-lived? Best regards, P.S.: There's also an AutoLoader patch of mine waiting for application, |
From l2ot9pa02@sneakemail.comSelfLoader.pm.diff--- SelfLoader.pm.orig 2007-02-27 15:10:29.000000000 +0100
+++ SelfLoader.pm 2007-12-18 11:47:14.000000000 +0100
@@ -88,7 +88,7 @@
local($/) = "\n";
while(defined($line = <$fh>) and $line !~ m/^__END__/) {
- if ($line =~ m/^sub\s+([\w:]+)\s*((?:\([\\\$\@\%\&\*\;]*\))?(?:$attr_list)?)/) {
+ if ($line =~ m/^\s*sub\s+([\w:]+)\s*((?:\([\\\$\@\%\&\*\;]*\))?(?:$attr_list)?)/) {
push(@stubs, $self->_add_to_cache($name, $currpack, \@lines, $protoype));
$protoype = $2;
@lines = ($line);
|
From l2ot9pa02@sneakemail.comSelfLoader.t.diff--- SelfLoader.t.orig 2006-06-13 21:29:18.000000000 +0200
+++ SelfLoader.t 2007-12-18 11:47:14.000000000 +0100
@@ -13,7 +13,7 @@
@INC = $dir;
push @INC, '../lib';
- print "1..19\n";
+ print "1..20\n";
# First we must set up some selfloader files
mkdir $dir, 0755 or die "Can't mkdir $dir: $!";
@@ -40,7 +40,6 @@
package sheep;
sub bleat { shift; shift || "baa" }
-
__END__
sub never { die "D'oh" }
EOT
@@ -56,6 +55,7 @@
sub new { bless {}, shift }
sub a;
+sub with_whitespace_in_front;
1;
__DATA__
@@ -63,6 +63,10 @@
sub a { 'a Bar'; }
sub b { 'b Bar' }
+ sub with_whitespace_in_front {
+ "with_whitespace_in_front Bar"
+}
+
__END__ DATA
sub never { die "D'oh" }
EOT
@@ -147,16 +151,20 @@
print "not " unless $bar->c() eq 'c Baz';
print "ok 12\n";
+# check that subs with whitespace in front work
+print "not " unless $bar->with_whitespace_in_front() eq 'with_whitespace_in_front Bar';
+print "ok 13\n";
+
# This selfloads Bar::a because it is stubbed. It also stubs Bar::b as a side
# effect
print "not " unless $bar->a() eq 'a Bar';
-print "ok 13\n";
+print "ok 14\n";
print "not " unless $bar->b() eq 'b Bar';
-print "ok 14\n";
+print "ok 15\n";
print "not " unless $bar->c() eq 'c Baz';
-print "ok 15\n";
+print "ok 16\n";
@@ -166,18 +174,18 @@
$foo->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 16\n";
+ print "ok 17\n";
} else {
- print "not ok 16 $@\n";
+ print "not ok 17 $@\n";
}
# Try to read from the data file handle
my $foodata = <Foo::DATA>;
close Foo::DATA;
if (defined $foodata) {
- print "not ok 17 # $foodata\n";
+ print "not ok 18 # $foodata\n";
} else {
- print "ok 17\n";
+ print "ok 18\n";
}
# Check that __END__ DATA is honoured
@@ -186,18 +194,18 @@
$bar->never;
};
if ($@ =~ /^Undefined subroutine/) {
- print "ok 18\n";
+ print "ok 19\n";
} else {
- print "not ok 18 $@\n";
+ print "not ok 19 $@\n";
}
# Try to read from the data file handle
my $bardata = <Bar::DATA>;
close Bar::DATA;
if ($bardata ne "sub never { die \"D'oh\" }\n") {
- print "not ok 19 # $bardata\n";
+ print "not ok 20 # $bardata\n";
} else {
- print "ok 19\n";
+ print "ok 20\n";
}
# cleanup
|
The RT System itself - Status changed from 'new' to 'open' |
@rgs - Status changed from 'open' to 'resolved' |
From @rgsOn 18/12/2007, Steffen Mueller <l2ot9pa02@sneakemail.com> wrote:
Thanks, applied as #32665, and $VERSION++.
I see no reason why it couldn't be dual-lived. |
From @rgsOn 20/12/2007, Steffen Mueller <l2ot9pa02@sneakemail.com> wrote:
Why so? you could test $] and use different code. (and release 1.13)
but the cpan toolchain doesn't support branches. (yet)
Like, when we'll have Perl 6 and Perl 5 in production. |
From @nwc10On Thu, Dec 20, 2007 at 10:55:05AM +0100, Rafael Garcia-Suarez wrote:
I'd find this really useful as then 5.8.9 could have the same version as Nicholas Clark |
From l2ot9pa02@sneakemail.comHi Rafael, Rafael Garcia-Suarez wrote:
there actually are some problems: - SelfLoader in 5.10 is version 1.11. Hence, backporting means having a CPAN release which doesn't use 5.10 Therefore, Any such dual-lived releases need, forever, have versions Or am I missing something? One might just have two tracks, one between Of course, this is a broader issue than just SelfLoader. It's bound to Best regards, |
From l2ot9pa02@sneakemail.comHi Rafael, hi p5p, Rafael Garcia-Suarez wrote:
I would think there are 5.10 features which don't even compile on 5.8. [...]
I'm not holding my breath! :) Best regards, |
From l2ot9pa02@sneakemail.comSteffen Mueller wrote:
Alternatively, one could test $] during Makefile.PL and install the I guess both approaches come with their own set of problems. The Steffen |
Migrated from rt.perl.org#48769 (status was 'resolved')
Searchable as RT48769$
The text was updated successfully, but these errors were encountered: