Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fwd: Rakudo Star silent exit on subset violation? #1987

Closed
p6rt opened this issue Jul 30, 2010 · 6 comments
Closed

Fwd: Rakudo Star silent exit on subset violation? #1987

p6rt opened this issue Jul 30, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jul 30, 2010

Migrated from rt.perl.org#76834 (status was 'resolved')

Searchable as RT76834$

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @coke

Opening a ticket on behalf of ovid...

---------- Forwarded message ----------
From​: Ovid <publiustemp-perl6compiler2@​yahoo.com>
Date​: Thu, Jul 29, 2010 at 9​:44 AM
Subject​: Rakudo Star silent exit on subset violation?
To​: perl6-compiler@​perl.org

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

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @perlpilot

Another data point .... if you just s/Int​:://g, it seems to DTRT​:

$ perl6 foo.p6
Constraint type check failed for parameter '$count'
  in 'lotto' at line 8​:foo.p6
  in main program body at line 13​:foo.p6

$ cat foo.p6

use v6;

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

sub lotto (Positive $count, 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);

-Scott

On Fri Jul 30 07​:14​:54 2010, coke wrote​:

Opening a ticket on behalf of ovid...

---------- Forwarded message ----------
From​: Ovid <publiustemp-perl6compiler2@​yahoo.com>
Date​: Thu, Jul 29, 2010 at 9​:44 AM
Subject​: Rakudo Star silent exit on subset violation?
To​: perl6-compiler@​perl.org

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

--
perlpilot

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @coke

On Fri Jul 30 07​:14​:54 2010, coke wrote​:

Opening a ticket on behalf of ovid...

---------- Forwarded message ----------
From​: Ovid <publiustemp-perl6compiler2@​yahoo.com>
Date​: Thu, Jul 29, 2010 at 9​:44 AM
Subject​: Rakudo Star silent exit on subset violation?
To​: perl6-compiler@​perl.org

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

This now (git-latest rakudo compiler) fails properly​:

$ ./perl6 foo
Constraint type check failed for parameter '$count'
  in sub lotto at foo​:1
  in block <anon> at foo​:6
  in <anon> at foo​:1

Closable with tests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 3, 2011

From @moritz

now tested in the ever-growing t/spec/S12-subset/subtypes.t

@p6rt
Copy link
Author

p6rt commented Oct 3, 2011

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 3, 2011
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant