I don't know if this is reported (I can't find a bug report for it).

I just downloaded and compiled Rakudo Star.

$ uname -a
Linux localhost.bbc.co.uk 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:22:14 
UTC 2010 i686 GNU/Linux

The bug:

    subset Int::Positive of Int where { $_ > 0 };

    sub lotto (Int::Positive $count, Int::Positive $range) returns List {
      die "$range must not be less than $count" if $range < $count;
      return (1 .. $range).pick($count);
    }
    .say for lotto(-3,10);
Note that the first argument to "lotto" is negative and thus violates the type 
constraint.  This code works fine if the first argument is a positive integer 
less than the second argument, but exits with no output otherwise. Making the 
second argument negative (and the first positive) hits the "die" line, so the 
type constraint is simply being ignored for negative numbers.

If I change the first argument to a float such as 3.2, it seems to round it up 
to 4.

Cheers,
Ovid--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://blogs.perl.org/users/ovid/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6


Reply via email to