Skip to content

Instantly share code, notes, and snippets.

@usev6
Created February 18, 2018 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usev6/b81dd9afb68cc55398c950c61760a0fc to your computer and use it in GitHub Desktop.
Save usev6/b81dd9afb68cc55398c950c61760a0fc to your computer and use it in GitHub Desktop.
diff fixing NullPointerException method clone(Array:D) {} and method clone(Hash:D) {}
diff --git a/src/core/Array.pm b/src/core/Array.pm
index 6fff8b91f..c435a9d51 100644
--- a/src/core/Array.pm
+++ b/src/core/Array.pm
@@ -51,14 +51,14 @@ my class Array { # declared in BOOTSTRAP
nqp::stmts(
(my \iter := self.iterator),
(my \result := nqp::p6bindattrinvres(nqp::create(self),
- Array, '$!descriptor', nqp::clone($!descriptor))),
+ Array, '$!descriptor', nqp::isnull($!descriptor) ?? Mu !! nqp::clone($!descriptor))),
nqp::if(
nqp::eqaddr(
IterationEnd,
iter.push-until-lazy:
my \target := ArrayReificationTarget.new(
(my \buffer := nqp::create(IterationBuffer)),
- nqp::clone($!descriptor))),
+ nqp::isnull($!descriptor) ?? Mu !! nqp::clone($!descriptor))),
nqp::p6bindattrinvres(result, List, '$!reified', buffer),
nqp::stmts(
nqp::bindattr(result, List, '$!reified', buffer),
diff --git a/src/core/Hash.pm b/src/core/Hash.pm
index 88739bcff..63068afda 100644
--- a/src/core/Hash.pm
+++ b/src/core/Hash.pm
@@ -43,7 +43,7 @@ my class Hash { # declared in BOOTSTRAP
nqp::p6bindattrinvres(
nqp::create(self),Map,'$!storage',
nqp::clone(nqp::getattr(self,Map,'$!storage'))),
- Hash, '$!descriptor', nqp::clone($!descriptor))
+ Hash, '$!descriptor', nqp::isnull($!descriptor) ?? Mu !! nqp::clone($!descriptor))
}
method !AT-KEY-CONTAINER(Str:D \key) is raw {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment