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

Inf not handled in Int array #4387

Closed
p6rt opened this issue Jul 8, 2015 · 5 comments
Closed

Inf not handled in Int array #4387

p6rt opened this issue Jul 8, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 8, 2015

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

Searchable as RT125576$

@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

From liukan@360.cn

http://irclog.perlgeek.de/perl6/2015-07-08#i_10865609

my Int @​a = 1 .. Inf;
@​a[*-1], @​a[*-Inf], @​a[Inf];

Cannot coerce Inf or NaN to an Int

@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

From @coke

On Wed Jul 08 05​:53​:44 2015, liukan@​360.cn wrote​:

http://irclog.perlgeek.de/perl6/2015-07-08#i_10865609

my Int @​a = 1 .. Inf;
@​a[*-1], @​a[*-Inf], @​a[Inf];

Cannot coerce Inf or NaN to an Int

This is related to https://rt-archive.perl.org/perl6/Ticket/Display.html?id=61602

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

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

@p6rt
Copy link
Author

p6rt commented Apr 26, 2017

From @zoffixznet

On Wed, 08 Jul 2015 05​:53​:44 -0700, liukan@​360.cn wrote​:

http://irclog.perlgeek.de/perl6/2015-07-08#i_10865609

my Int @​a = 1 .. Inf;
@​a[*-1], @​a[*-Inf], @​a[Inf];

Cannot coerce Inf or NaN to an Int

Closing this, as the `@​a[*-1]` mentioned in the IRC log now rightly complains about lazy lists. (Added a vaguish test for it in Raku/roast@ada48a6538 )

The fact that `my Int @​a = 1..Inf;` or even `m​: my Int @​a = lazy 1, NaN, Int;` does not throw is not a bug. The `@​` sigil is mostly-eager and it does not reify stuff that .is-lazy on assignment, so *it has no idea* some of the elements are not of the appropriate type and would need to be able to time travel to throw there and then.

If you do reify the array, then throwage does happen when you reach inappropriate type​:

  m​: my Int @​a = lazy 1, NaN, Int; .say for @​a
  rakudo-moar 9f0b12​: OUTPUT​: «1â�¤Type check failed in assignment to @​a; expected Int but got Num (NaN)â�¤ in block <unit> at <tmp> line 1â�¤â�¤

Lastly, some of the other errors mentioned in the IRC log aren't due to Inf in the array, but due to trying to use a non-Intifying thing as an Array index​:

  <ZoffixW> m​: [][Inf]
  <camelia> rakudo-moar 9f0b12​: OUTPUT​: «Cannot coerce Inf to an Intâ�¤ in block <unit> at <tmp> line 1â�¤â�¤Actually thrown at​:â�¤ in block <unit> at <tmp> line 1â�¤â�¤Â»
  <ZoffixW> m​: [][i]
  <camelia> rakudo-moar 9f0b12​: OUTPUT​: «Can not convert 0+1i to Int​: imaginary part not zeroâ�¤ in block <unit> at <tmp> line 1â�¤â�¤Actually thrown at​:â�¤ in block <unit> at <tmp> line 1â�¤â�¤Â»

@p6rt p6rt closed this as completed Apr 26, 2017
@p6rt
Copy link
Author

p6rt commented Apr 26, 2017

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

@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