Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a number of edge cases in Pair.perl
Spotted by zefram++ , cases such as Nil => 42 vs (Nil) => 42.  I also found
two other edge cases: NaN and Inf as a left hand side
  • Loading branch information
lizmat committed Dec 13, 2015
1 parent 5308479 commit 5b6cbc7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/Pair.pm
Expand Up @@ -45,13 +45,16 @@ my class Pair does Associative {

multi method perl(Pair:D: :$arglist) {
self.perlseen('Pair', -> :$arglist {
nqp::istype($!key, Pair)
?? '(' ~ $!key.perl ~ ') => ' ~ $!value.perl
!! nqp::istype($!key, Str) && !$arglist && $!key ~~ /^ [<alpha>\w*] +% <[\-']> $/
nqp::istype($!key, Str)
?? !$arglist && $!key ~~ /^ [<alpha>\w*] +% <[\-']> $/
?? nqp::istype($!value,Bool)
?? ':' ~ '!' x !$!value ~ $!key
!! ':' ~ $!key ~ '(' ~ $!value.perl ~ ')'
!! $!key.perl ~ ' => ' ~ $!value.perl
!! nqp::istype($!key, Numeric)
&& !(nqp::istype($!key,Num) && nqp::isnanorinf($!key))
?? $!key.perl ~ ' => ' ~ $!value.perl
!! '(' ~ $!key.perl ~ ') => ' ~ $!value.perl
}, :$arglist)
}

Expand Down

0 comments on commit 5b6cbc7

Please sign in to comment.