develooper Front page | perl.perl6.compiler | Postings from January 2012

[perl #77164] [BUG] Cannot always match signature when default value is a sub

From:
Will Coleda via RT
Date:
January 11, 2012 07:55
Subject:
[perl #77164] [BUG] Cannot always match signature when default value is a sub
Message ID:
rt-3.6.HEAD-14510-1326297350-839.77164-15-0@perl.org
On Wed Aug 11 08:58:45 2010, patrickas wrote:
> <patrickas> rakudo: sub foo ( $f = rand ) { say $f; }; say
> Capture.new() ~~ &foo.signature;  #does not match
> <p6eval> rakudo c1e19a: OUTPUT«0␤»
> 
> <patrickas> rakudo: sub foo ( $f = 0.461541885367723 ) { say $f;  };
> say Capture.new() ~~ &foo.signature;  #matches
> <p6eval> rakudo c1e19a: OUTPUT«1␤»
> 
> <patrickas> rakudo: sub foo ( $f = substr('string',0) ) { say $f; };
> say Capture.new() ~~ &foo.signature; #matches
> <p6eval> rakudo c1e19a: OUTPUT«1␤»

These now all fail to smartmatch, which I don't think is the requested 
behavior; is it the spec'd behavior?

-- 
Will "Coke" Coleda



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About