On Mon, Mar 07, 2005 at 06:08:21PM -0500, Stevan Little wrote: > Autrijus and Co. > > I have found another weird bug. It apprears to be a problem with the > way the return statement handles Array refs and Hash refs in scalar > context. I have some tests in t/op/sub_return_values.t which test the > array ref problem.
I also found a precedence bug with return while I was adding some tests according to apocalypse & synopsis 6 (tests attached, with some todo_is tests for "is rw" prototypes and named args passing). I am looking at the code, but since this is the first time I've ever used haskell, I haven't figured out how to fix it. The failing test is: sub numcmp ($x, $y) { return $x <=> $y } is(numcmp(2,7),-1,"numcmp 1"); it seems that numcmp returns $x instead of the value of the <=> statement code taken from the top of: http://www.perl.com/pub/a/2003/04/09/synopsis.html?page=2 Joost.
Index: t/06sub.t =================================================================== --- t/06sub.t (revision 524) +++ t/06sub.t (working copy) @@ -9,7 +9,7 @@ =cut -plan 12; +plan 17; sub foobar ($var) { return $var; @@ -70,3 +70,29 @@ is($_, "-wibble-", 'sub closures close'); $_ = $block.(); is($_, "-quux-", 'block closures close'); + + +sub prototype_default { + return @_; +} +my @in = qw(1 2 3 4); +my @out = prototype_default(@in); +is ("@out[]","1 2 3 4","Default prototype"); + +sub prototype_default_explicit([EMAIL PROTECTED]) { + return @_; +} [EMAIL PROTECTED] = prototype_default_explicit(@in); +is ("@out[]","1 2 3 4","Explicit default prototype"); + +todo_is(eval( +'sub swap ([EMAIL PROTECTED] is rw) { @_[0,1] = @_[1,0]; } [EMAIL PROTECTED] = qw(1 2); +swap(@in); [EMAIL PROTECTED]'), +"2 1","swap"); + +sub numcmp ($x, $y) { return $x <=> $y } +is(numcmp(2,7),-1,"numcmp 1"); +todo_is(eval('numcmp( y => 7, x => 2 )'),-1,"numcmp 2"); +