From: Simon Cozens Date: Wed, 27 Dec 2000 14:12:44 +0000 (+0000) Subject: Re: [ID 19991001.003] sort(sub(arg)) misparsed as sort sub args X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0670693ff29ac8dc3df00d73b858a9d736644ed;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 19991001.003] sort(sub(arg)) misparsed as sort sub args Message-ID: <20001227141244.A13344@deep-dark-truthful-mirror.perlhacker.org> p4raw-id: //depot/perl@8239 --- diff --git a/t/op/method.t b/t/op/method.t index be4df75..1f5cbb6 100755 --- a/t/op/method.t +++ b/t/op/method.t @@ -9,7 +9,7 @@ BEGIN { @INC = '../lib'; } -print "1..53\n"; +print "1..54\n"; @A::ISA = 'B'; @B::ISA = 'C'; @@ -185,3 +185,8 @@ test(do { eval 'E->foo()'; 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); diff --git a/t/op/sort.t b/t/op/sort.t index 9095871..c1dfb63 100755 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } use warnings; -print "1..57\n"; +print "1..58\n"; # XXX known to leak scalars { @@ -321,3 +321,10 @@ sub cxt_six { sort test_if_scalar 1,2 } 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"; +} diff --git a/toke.c b/toke.c index cd6ed1d..46278e8 100644 --- a/toke.c +++ b/toke.c @@ -3915,10 +3915,10 @@ Perl_yylex(pTHX) /* 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;