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

.new of subclasses of Int returns an Int #6539

Closed
p6rt opened this issue Sep 19, 2017 · 5 comments
Closed

.new of subclasses of Int returns an Int #6539

p6rt opened this issue Sep 19, 2017 · 5 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Sep 19, 2017

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

Searchable as RT132128$

@p6rt
Copy link
Author

p6rt commented Sep 19, 2017

From @zoffixznet

  m​: class Foo is Int {}; my Foo $x .= new​: 42; say $x; say $x.WHAT;
  rakudo-moar bb4579​: OUTPUT​: «Type check failed in assignment to $x; expected Foo but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»

This was broken by the fix to make it correctly handle >64bit ints, but apparently there are even articles that show how to subclass Ints​: https://irclog.perlgeek.de/perl6/2017-09-19#i_15187511

The likely fix would be Int.new changed to this​:

  method new (Int() \value) {
  nqp​::p6bindattrinvres(self.bless, Int, q|$!value|, nqp​::getattr(nqp​::decont(value), Int, q|$!value|))
  }

But that currently segfaults​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132126

@p6rt
Copy link
Author

p6rt commented Sep 19, 2017

From @zoffixznet

On Tue, 19 Sep 2017 08​:23​:07 -0700, cpan@​zoffix.com wrote​:

m​: class Foo is Int {}; my Foo $x .= new​: 42; say $x; say $x.WHAT;
rakudo-moar bb4579​: OUTPUT​: «Type check failed in assignment to $x;
expected Foo but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»

This was broken by the fix to make it correctly handle >64bit ints,
but apparently there are even articles that show how to subclass Ints​:
https://irclog.perlgeek.de/perl6/2017-09-19#i_15187511

The likely fix would be Int.new changed to this​:

method new (Int() \value) {
nqp​::p6bindattrinvres(self.bless, Int, q|$!value|,
nqp​::getattr(nqp​::decont(value), Int, q|$!value|))
}

But that currently segfaults​:
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132126

Fixed in​: rakudo/rakudo@0834036dd4
Tests in​: Raku/roast@ba7d5c1dd1

@p6rt
Copy link
Author

p6rt commented Sep 20, 2017

From @skids

On Tue, 19 Sep 2017 11​:12​:23 -0700, cpan@​zoffix.com wrote​:

On Tue, 19 Sep 2017 08​:23​:07 -0700, cpan@​zoffix.com wrote​:

m​: class Foo is Int {}; my Foo $x .= new​: 42; say $x; say $x.WHAT;
rakudo-moar bb4579​: OUTPUT​: «Type check failed in assignment to $x;
expected Foo but got Int (42)␤ in block <unit> at <tmp> line 1␤␤»

This was broken by the fix to make it correctly handle >64bit ints,
but apparently there are even articles that show how to subclass Ints​:
https://irclog.perlgeek.de/perl6/2017-09-19#i_15187511

The likely fix would be Int.new changed to this​:

method new (Int() \value) {
nqp​::p6bindattrinvres(self.bless, Int, q|$!value|,
nqp​::getattr(nqp​::decont(value), Int, q|$!value|))
}

But that currently segfaults​:
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132126

Fixed in​: rakudo/rakudo@0834036dd4
Tests in​: Raku/roast@ba7d5c1dd1

In that case, resolving the ticket.

@p6rt
Copy link
Author

p6rt commented Sep 20, 2017

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

@p6rt
Copy link
Author

p6rt commented Sep 20, 2017

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

@p6rt p6rt closed this as completed Sep 20, 2017
@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant