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

1/0 results in a Failure complaining about an expected Int type in Rakudo #3568

Closed
p6rt opened this issue Oct 28, 2014 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 28, 2014

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

Searchable as RT123077$

@p6rt
Copy link
Author

p6rt commented Oct 28, 2014

From @masak

<moritz> m​: my $x = 1/ 0; $x.gist
<camelia> rakudo-moar 315ec6​: OUTPUT«Type check failed for return
value; expected 'Int' but got 'Failure' [...]
<moritz> that looks like a bug to me
<masak> moritz​: agreed.
<masak> moritz​: do you want to rakudobug it, or shall I?
<moritz> masak​: please do
* masak does, pleased
<masak> moritz​: ooc and for the record, did you expect `my $x = 1/ 0`
to fail? if so, how? or, if you expected it to succeed, what value did
you expect in $x ?
<moritz> masak​: I didn't know if it would fail or die
<moritz> masak​: but I expected that if it was a Failure, .gist would
throw a "division by zero" exception
<arnsholt> I guess I'd expect $x to either be a Failure or a NaN
<moritz> arnsholt​: since there are no Nums involved, I'd find a NaN rather weird
<masak> Java has integer 1/0 as a (runtime) error, but float/double
1.0/0.0 as a NaN.
<masak> m​: say Rat.new(1, 0).perl
<camelia> rakudo-moar 315ec6​: OUTPUT«<1/0>␤»
<masak> S03 seems to indicate that that's the intended answer.
<masak> at least reading it by the letter, and seeing no exception in
place for integral division by 0.
<masak> ...except if this implicitly mean that Perl 6 is like Perl 5
in this regard, in which case it should die with "Illegal division by
zero" at runtime.
<moritz> I'm even fine with an <1/0> literal, as long as it .gist()s sensibly
* masak .oO( rakudo-moar 315ec6​: OUTPUT«<1/0>, you knucklehead!␤» )

@p6rt
Copy link
Author

p6rt commented Jan 13, 2015

From @lizmat

On 28 Oct 2014, at 21​:23, Carl Mäsak (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "Carl Mäsak"
# Please include the string​: [perl #​123077]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123077 >

<moritz> m​: my $x = 1/ 0; $x.gist
<camelia> rakudo-moar 315ec6​: OUTPUT«Type check failed for return
value; expected 'Int' but got 'Failure' [...]
<moritz> that looks like a bug to me
<masak> moritz​: agreed.
<masak> moritz​: do you want to rakudobug it, or shall I?
<moritz> masak​: please do
* masak does, pleased
<masak> moritz​: ooc and for the record, did you expect `my $x = 1/ 0`
to fail? if so, how? or, if you expected it to succeed, what value did
you expect in $x ?
<moritz> masak​: I didn't know if it would fail or die
<moritz> masak​: but I expected that if it was a Failure, .gist would
throw a "division by zero" exception
<arnsholt> I guess I'd expect $x to either be a Failure or a NaN
<moritz> arnsholt​: since there are no Nums involved, I'd find a NaN rather weird
<masak> Java has integer 1/0 as a (runtime) error, but float/double
1.0/0.0 as a NaN.
<masak> m​: say Rat.new(1, 0).perl
<camelia> rakudo-moar 315ec6​: OUTPUT«<1/0>␤»
<masak> S03 seems to indicate that that's the intended answer.
<masak> at least reading it by the letter, and seeing no exception in
place for integral division by 0.
<masak> ...except if this implicitly mean that Perl 6 is like Perl 5
in this regard, in which case it should die with "Illegal division by
zero" at runtime.
<moritz> I'm even fine with an <1/0> literal, as long as it .gist()s sensibly
* masak .oO( rakudo-moar 315ec6​: OUTPUT«<1/0>, you knucklehead!␤» )

After 9672c0df736cde4602036e4f6e137b6c4bc7209d :

$ 6 'my $x = 1/ 0; $x.gist'
Divide by zero

Liz

@p6rt
Copy link
Author

p6rt commented Jan 13, 2015

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

@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

From @usev6

The error message also mentions the operator now (and .gist still dies with X​::Numeric​::DivideByZero)​:

$ perl6-m -e 'my $x = 1 % 0; say "still alive"; $x.gist'
still alive
Attempt to divide 1 by zero using infix​:<%>
  in block <unit> at -e​:1

I added a test to S03-operators/arith.t with commit Raku/roast@6ea448b9a2

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

From @usev6

The error message also mentions the operator now (and .gist still dies with X​::Numeric​::DivideByZero)​:

$ perl6-m -e 'my $x = 1 % 0; say "still alive"; $x.gist'
still alive
Attempt to divide 1 by zero using infix​:<%>
  in block <unit> at -e​:1

I added a test to S03-operators/arith.t with commit Raku/roast@6ea448b9a2

I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Jun 20, 2015

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

@p6rt p6rt closed this as completed Jun 20, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant