-
Notifications
You must be signed in to change notification settings - Fork 1
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
NullPointerException when using sub form of map on array with deleted element #5356
Comments
From @usev6The following code (tested in S32-array/delete.t) started to fail with rakudo-j recently: $ perl6-j -e 'my @a = 0..1; @a[0]:delete; map { 1 }, @a' $ perl6-j --ll-exception -e 'my @a = 0..1; @a[0]:delete; map { 1 }, @a' I think, the error first appeared with Rakudo commit beb3c986. The following patch makes the NPE go away (and has no spectest fallout). But I'm not sure if it is the right thing to insert Nil when nqp::atpos returns null. ==== Inline Patchdiff --git a/src/core/List.pm b/src/core/List.pm
index 0c65a6f..ddc8607 100644
--- a/src/core/List.pm
+++ b/src/core/List.pm
@@ -476,7 +476,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
method push-all($target) {
my int $elems = nqp::elems($!reified);
my $no-sink;
- $no-sink := $target.push(nqp::atpos($!reified,$!i))
+ $no-sink := $target.push(nqp::ifnull(nqp::atpos($!reified,$!i),Nil))
while nqp::islt_i($!i = nqp::add_i($!i,1),$elems);
IterationEnd
} |
From @lizmatThe weird thing here is, is that somehow the List.iterator is used, instead of the Array.iterator (which *does* take null values into account, even makes them bindable) Is this still a problem on HEAD ? Liz
|
The RT System itself - Status changed from 'new' to 'open' |
From @usev6On Sat Jun 04 11:45:51 2016, bartolin@gmx.de wrote:
However, PR created: rakudo/rakudo#780 |
From @usev6On Sat Jun 04 13:20:25 2016, elizabeth wrote:
Oops, didn't see your reply before posting my comment. Yes, it's still a problem on HEAD. I'm not really sure, but I think the NPE happens because somewhere in 'sub map' or 'method map' is a call to .list and we end up in List.iterator. Without the 'map' there is no problem: $ perl6-j -e 'my @array = 0..1; @array[0]:delete; say @array' |
From @usev6On Sat Jun 04 13:30:58 2016, bartolin@gmx.de wrote:
Ah, here (src/core/Any-iterable-methods.pm:1371) is what made me assume that map caused us to end up in List.iterator -- values seems to be a List here: multi sub map(&code, +values) { my $laze = values.is-lazy; values.map(&code).lazy-if($laze) } |
From @usev6On Sat Jun 04 14:10:20 2016, bartolin@gmx.de wrote:
Another thing to note: Only the sub form of map has the problem: $ perl6-j -e 'my @array = 0..1; @array[0]:delete; say map { $_ }, @array' $ perl6-j -e 'my @array = 0..1; @array[0]:delete; say @array.map( { $_ } )' See also my latest comment on the PR: rakudo/rakudo#780 (comment) |
From @usev6Yesterday we had the following discussion on #perl6-dev about this ticket: ==== start of discussion on IRC -- cmp. http://irclog.perlgeek.de/perl6-dev/2016-09-19#i_13238477 |
1 similar comment
From @usev6Yesterday we had the following discussion on #perl6-dev about this ticket: ==== start of discussion on IRC -- cmp. http://irclog.perlgeek.de/perl6-dev/2016-09-19#i_13238477 |
From @usev6This problem has been resolved: $ ./perl6-j -e 'my @array = 0..1; @array[0]:delete; say map { $_ }, @array' The test in S32-array/delete.t is passing on the JVM backend as well. I'm closing this ticket as 'resolved'. |
1 similar comment
From @usev6This problem has been resolved: $ ./perl6-j -e 'my @array = 0..1; @array[0]:delete; say map { $_ }, @array' The test in S32-array/delete.t is passing on the JVM backend as well. I'm closing this ticket as 'resolved'. |
@usev6 - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#128320 (status was 'resolved')
Searchable as RT128320$
The text was updated successfully, but these errors were encountered: