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

Can't subtract freaky Int in Rakudo #2611

Closed
p6rt opened this issue Jan 12, 2012 · 5 comments
Closed

Can't subtract freaky Int in Rakudo #2611

p6rt opened this issue Jan 12, 2012 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 12, 2012

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

Searchable as RT108052$

@p6rt
Copy link
Author

p6rt commented Jan 12, 2012

From @masak

<masak> ./perl6 -e 'sub MAIN(Int $a) { say $a - 5 }' 7
<masak> 7
<masak> :10($a) is a workaround so far.
<masak> ./perl6 -e 'sub MAIN(Int $a) { say :10($a) - 5 }' 7
<masak> 2
<moritz> confirmed.
<masak> can anyone confirm?
* masak submits rakudobug
<moritz> I guess it's the mixing in of the current string form that's
bothering the multi dispatcher
<masak> I'm sure it is.

@p6rt
Copy link
Author

p6rt commented Jan 12, 2012

From @masak

On Thu Jan 12 02​:02​:04 2012, masak wrote​:

<masak> ./perl6 -e 'sub MAIN(Int $a) { say $a - 5 }' 7
<masak> 7
<masak> :10($a) is a workaround so far.
<masak> ./perl6 -e 'sub MAIN(Int $a) { say :10($a) - 5 }' 7
<masak> 2
<moritz> confirmed.
<masak> can anyone confirm?
* masak submits rakudobug
<moritz> I guess it's the mixing in of the current string form that's
bothering the multi dispatcher
<masak> I'm sure it is.

<moritz> OMG
<moritz> bigints are to blame
<masak> o.O
<moritz> the bigint operations need to generate a new bigint object
<moritz> and they try to create one of the right type
<moritz> ... by chosing the type of one of the arguments
<moritz> and here it happens to be the type of the first argument
<moritz> and that turns out to be less clever than we would have hoped
:/
<moritz> the fix is to add an additional parameter for the type object
of the result to nearly all bigint ops
<jnthn> :/
* masak adds this to the ticket
<moritz> the result is a proper 5, it just stringifies to 7
<moritz> nom​: my role orig-string[$o] { method Str() { $o.Str } }; my $a
= 7 but orig-string['7']; say nqp​::p6box_s(nqp​::unbox_i($a - 2))
<p6eval> nom f365ad​: OUTPUT«5␤»
<jnthn> moritz​: If somebody sends a subclass in, are we expecting to
drop that in the type of the result?
<jnthn> Guess we could...
<moritz> jnthn​: I don't think we are supposed to do any automagic
polymorphy in the int ops...
<jnthn> moritz​: Yeah, I hoped we'd get away with this and save a lookup.
<moritz> how could we possibly know what to do with A + B where both A
and B inherit from Int, if not returning Int?
<jnthn> moritz​: Guess wildly :)
<jnthn> moritz​: Anyway, yeah, we probably should be returning an Int.
<moritz> jnthn​: that's what led to RT #​108052 :/ (guessing wildly)
* jnthn shoulda guessed somebody would run into this in the space of
weeks rather than years. :/
<masak> guess who ran into it... :)
<moritz> 'masak' given 'somebody' :-)

@p6rt
Copy link
Author

p6rt commented Jan 12, 2012

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 15, 2012

From @moritz

This has been fixed with the merge of the bigint-type branch, and is
tetsed in S03-operators/arith.t

@p6rt
Copy link
Author

p6rt commented Jan 15, 2012

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

@p6rt p6rt closed this as completed Jan 15, 2012
@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