Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Bugs
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stevan Little  
View profile  
 More options Mar 7 2005, 6:08 pm
Newsgroups: perl.perl6.compiler
From: ste...@iinteractive.com (Stevan Little)
Date: Mon, 7 Mar 2005 18:08:21 -0500
Local: Mon, Mar 7 2005 6:08 pm
Subject: [Pugs] Bugs
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 will try and flesh out the hash-ref tests in the
same file later tonight. But anyway here is a description of the bug.

The following code:
     pugs -e 'sub foo { return [ 1, 2, 3 ] }; my $test = foo(); say
$test; say ref($test);'
will print out:
     3
     Int

While all of the following code:
     pugs -e 'sub foo { [ 1, 2, 3 ] }; my $test = foo(); say $test; say
ref($test);'
     pugs -e 'sub foo { return ( 1, 2, 3 ) }; my @test = foo(); say
@test; say ref(@test);'
     pugs -e 'sub foo { return [ 1, 2, 3 ] }; my @test = foo(); say
@test; say ref(@test);'
will print out:
     123
     List

I also suspect that the same bug is causing this code:
     pugs -e 'sub foo { my %h = ("one",1,"two",2,"three",3); return \%h;

}; my $test = foo(); say $test; say ref($test);'

to print out:
     two2
     Pair

because all of these (note the lack of return statement):
        pugs -e 'sub foo { my %h = ("one",1,"two",2,"three",3); \%h; }; my
$test = foo(); say $test; say ref($test);'
        pugs -e 'sub foo { my %h = ("one",1,"two",2,"three",3); %h; }; my
$test = foo(); say $test; say ref($test);'

will print out:
     one     1
     three   3
     two     2
     Hash

Then there is this code:
        pugs -e 'sub foo { my %h = ("one",1,"two",2,"three",3); return %h; };
my %test = foo(); say %test; say ref(%test);'

which won't even compile. The error is spits out is:

Fail: cannot cast into [VPair]: VSub (Sub {isMulti = False, subName =
"&foo", subType = SubRoutine, subPad = [], subAssoc = "pre", subParams
= [Param {isInvocant = False, isSlurpy = True, isOptional = False,
isNamed = True, isLValue = False, paramName = "@_", paramContext =
"List", paramDefault = Val VUndef}], subReturns = "Any", subFun =
Statements [(Syn "sym" [Sym (Symbol {symScope = SMy, symName = "%h",
symExp = Syn "mval" [Var "%h",Syn "," [Syn "," [Syn "," [Syn "," [Syn
"," [Syn "cxt" [Val (VStr "Str"),App "&infix:~" [Val (VStr "one"),Val
(VStr "")] []],Val (VInt 1)],Syn "cxt" [Val (VStr "Str"),App "&infix:~"
[Val (VStr "two"),Val (VStr "")] []]],Val (VInt 2)],Syn "cxt" [Val
(VStr "Str"),App "&infix:~" [Val (VStr "three"),Val (VStr "")] []]],Val
(VInt 3)]]})],"-" (line 1, column 11)),(App "&return" [Var "%h"] [],"-"
(line 1, column 48))]})

I suspect this to might be a symptom of the above bug, but I cannot
tell for sure.

Anyway, Hope this helps out some.

- Steve


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Bugs (another return statement bug)" by Joost Diepenmaat
Joost Diepenmaat  
View profile  
 More options Mar 8 2005, 6:41 am
Newsgroups: perl.perl6.compiler
From: jo...@zeekat.nl (Joost Diepenmaat)
Date: Tue, 8 Mar 2005 12:41:40 +0100
Local: Tues, Mar 8 2005 6:41 am
Subject: Re: [Pugs] Bugs (another return statement bug)

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.

  subtests.patch
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joost Diepenmaat  
View profile  
 More options Mar 8 2005, 6:49 am
Newsgroups: perl.perl6.compiler
From: jo...@zeekat.nl (Joost Diepenmaat)
Date: Tue, 8 Mar 2005 12:49:54 +0100
Local: Tues, Mar 8 2005 6:49 am
Subject: Re: [Pugs] Bugs (another return statement bug)

On Tue, Mar 08, 2005 at 12:41:40PM +0100, Joost Diepenmaat wrote:
> +todo_is(eval(
> +'sub swap (*@_ is rw) { @_[0,1] = @_[1,0]; }
> +@in = qw(1 2);
> +swap(@in);
> +@in'),
> +"2 1","swap");

Meh. That's wrong.

it shoud be:

todo_is(eval(
'sub swap (*@_ is rw) { @_[0,1] = @_[1,0]; }
@in = qw(1 2);
swap(@in);
"@in[]"'),
"2 1","swap");

Fixed patch attached.

Joost.

  subtests.patch
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »