-
Notifications
You must be signed in to change notification settings - Fork 558
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
sort(sub(args)) misparsed as sort sub args #669
Comments
From sburke@netadventure.netI found this bug (at least I consider it a bug) while trying to apply I can understand that as a correct reading for I note that *************************************************************************** Note the output of this sample program: ttyp5 sburke ~ stonehenge 20: perl
Here's my version info: Characteristics of this binary (from libperl): I get identical results on a box with this config info: lachler ~ musca:pts/24 3: perl -V Characteristics of this binary (from libperl): And even on MacPerl 5.2.0r4 (patchlevel 5.004) with the following -V: Characteristics of this binary (from libperl): Here's an extended test program. Lines for B and C print '5'; all BEGIN{$^W = 1} print "A>", join(" ", zoz(5) ), "\n"; print "C>", join(" ", sort(zoz(5) ) ), "\n"; print "D>", join(" ", sort {$a cmp $b} zoz(5) ), "\n"; # works -- |
From [Unknown Contact. See original ticket]Still true as of 8221. -spp SHORT STORY: I found this bug (at least I consider it a bug) while trying to apply I can understand that as a correct reading for I note that *************************************************************************** Note the output of this sample program: ttyp5 sburke ~ stonehenge 20: perl
|
From @simoncozensOn Thu, Dec 21, 2000 at 03:50:14PM -0500, Stephen P. Potter wrote:
It's a deliberate decision, although a slightly wacky one. if ( ( PL_last_lop_op == OP_SORT || I think that first condition should change, but the fact that it's there and Oh, well, this doesn't break anything: Inline Patch--- toke.c~ Sun Dec 24 01:05:20 2000
+++ toke.c Sun Dec 24 01:19:26 2000
@@ -3915,10 +3915,10 @@
/* If not a declared subroutine, it's an indirect object. */
/* (But it's an indir obj regardless for sort.) */
- if ((PL_last_lop_op == OP_SORT ||
- (!immediate_paren && (!gv || !GvCVu(gv)))) &&
+ if ( (PL_last_lop_op == OP_SORT && !immediate_paren) ||
+ ((!gv || !GvCVu(gv)) &&
(PL_last_lop_op != OP_MAPSTART &&
- PL_last_lop_op != OP_GREPSTART))
+ PL_last_lop_op != OP_GREPSTART)))
{
PL_expect = (PL_last_lop == PL_oldoldbufptr) ? XTERM : XOPERATOR;
goto bareword;
--- t/op/sort.t~ Sun Dec 24 01:20:45 2000
+++ t/op/sort.t Sun Dec 24 01:22:19 2000
@@ -5,7 +5,7 @@
@INC = '../lib';
}
use warnings;
-print "1..57\n";
+print "1..58\n";
# XXX known to leak scalars
{
@@ -320,4 +320,11 @@
print ("@b" eq '1 2 3 4' ? "ok 56\n" : "not ok 56\n");
print "# x = '@b'\n";
print !$def ? "ok 57\n" : "not ok 57\n";
+}
+
+# Bug 19991001.003
+{
+ sub routine { "one", "two" };
+ @a = sort(routine(1));
+ print "@a" eq "one two" ? "ok 58\n" : "not ok 58\n";
} |
From @simoncozensOn Sun, Dec 24, 2000 at 01:23:01AM +0000, Simon Cozens wrote:
Yes it does. Let's try again. Man, that's some really tortuous logic in toke.c. Inline Patch--- t/op/method.t~ Wed Dec 27 14:03:40 2000
+++ t/op/method.t Wed Dec 27 14:10:15 2000
@@ -9,7 +9,7 @@
@INC = '../lib';
}
-print "1..53\n";
+print "1..54\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -185,3 +185,8 @@
test(do { eval '$e = bless {}, "E"; $e->foo()';
$@ =~ /^\QCan't locate object method "foo" via package "E" (perhaps / ? 1 : $@}, 1);
+# This is actually testing parsing of indirect objects and undefined subs
+# print foo("bar") where foo does not exist is not an indirect object.
+# print foo "bar" where foo does not exist is an indirect object.
+eval { sub AUTOLOAD { "ok ", shift, "\n"; } };
+print nonsuch(++$cnt);
--- t/op/sort.t~ Sun Dec 24 01:20:45 2000
+++ t/op/sort.t Sun Dec 24 01:22:19 2000
@@ -5,7 +5,7 @@
@INC = '../lib';
}
use warnings;
-print "1..57\n";
+print "1..58\n";
# XXX known to leak scalars
{
@@ -320,4 +320,11 @@
print ("@b" eq '1 2 3 4' ? "ok 56\n" : "not ok 56\n");
print "# x = '@b'\n";
print !$def ? "ok 57\n" : "not ok 57\n";
+}
+
+# Bug 19991001.003
+{
+ sub routine { "one", "two" };
+ @a = sort(routine(1));
+ print "@a" eq "one two" ? "ok 58\n" : "not ok 58\n";
}
--- toke.c~ Sun Dec 24 01:05:20 2000
+++ toke.c Wed Dec 27 14:00:46 2000
@@ -3915,10 +3915,10 @@
/* If not a declared subroutine, it's an indirect object. */
/* (But it's an indir obj regardless for sort.) */
- if ((PL_last_lop_op == OP_SORT ||
- (!immediate_paren && (!gv || !GvCVu(gv)))) &&
+ if ( !immediate_paren && (PL_last_lop_op == OP_SORT ||
+ ((!gv || !GvCVu(gv)) &&
(PL_last_lop_op != OP_MAPSTART &&
- PL_last_lop_op != OP_GREPSTART))
+ PL_last_lop_op != OP_GREPSTART))))
{
PL_expect = (PL_last_lop == PL_oldoldbufptr) ? XTERM : XOPERATOR;
goto bareword; |
Migrated from rt.perl.org#1549 (status was 'resolved')
Searchable as RT1549$
The text was updated successfully, but these errors were encountered: