Skip to content

Commit

Permalink
Fix incorrect use of nqp::iscont
Browse files Browse the repository at this point in the history
In these places, nqp::iscont was being used to see if the target
was a writeable container.  nqp::iscont only guarantees there's a
container.  nqp::isrwcont guarantees a writeable (assigneable) one.
  • Loading branch information
lizmat committed Mar 24, 2022
1 parent aed2786 commit 90d876a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core.c/Hash.pm6
Expand Up @@ -438,7 +438,7 @@ my class Hash { # declared in BOOTSTRAP
nqp::bindkey(
new-storage,
nqp::iterkey_s(iter),
nqp::if( nqp::iscont(v),
nqp::if( nqp::isrwcont(v),
nqp::p6assign(nqp::p6scalarfromdesc(nqp::getattr(self, Hash, '$!descriptor')), v),
v ))));
handle
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Hash/Object.pm6
Expand Up @@ -306,7 +306,7 @@ my role Hash::Object[::TValue, ::TKey] does Associative[TValue] {
nqp::iterkey_s(iter),
Pair.new(
p.key,
nqp::if( nqp::iscont(my \v = p.value),
nqp::if( nqp::isrwcont(my \v = p.value),
nqp::p6assign(nqp::p6scalarfromdesc(nqp::getattr(self, Hash, '$!descriptor')), v),
v )))));
handle
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/List.pm6
Expand Up @@ -514,7 +514,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}

method ASSIGN-POS(List:D: Int:D $pos, \what) is raw {
nqp::iscont(my $target := self.AT-POS($pos))
nqp::isrwcont(my $target := self.AT-POS($pos))
?? ($target = what)
!! X::Assignment::RO.new(value => self).throw
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Map.pm6
Expand Up @@ -292,7 +292,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
multi method ASSIGN-KEY(Map:D: \key, Mu \new) {
nqp::isnull(my \old := nqp::atkey($!storage,key.Str))
?? die("Cannot add key '{key}' to an immutable {self.^name}")
!! nqp::iscont(old)
!! nqp::isrwcont(old)
?? (old = new)
!! die("Cannot change key '{key}' in an immutable {self.^name}")
}
Expand Down
4 changes: 2 additions & 2 deletions src/core.c/Proc/Async.pm6
Expand Up @@ -151,7 +151,7 @@ my class Proc::Async {
type = value;
the-supply //= Supplier::Preserving.new;

if nqp::iscont(fd-vow) {
if nqp::isrwcont(fd-vow) {
my $native-descriptor := Promise.new;
fd-vow = $native-descriptor.vow;
Pipe.new(the-supply.Supply.Tappable, $native-descriptor, |self!pipe-cbs(permit-channel))
Expand All @@ -164,7 +164,7 @@ my class Proc::Async {
method !wrap-decoder(Supply:D $bin-supply, $enc, \fd-vow, \permit-channel, :$translate-nl) {
my \sup = Rakudo::Internals.BYTE_SUPPLY_DECODER($bin-supply, $enc // $!enc,
:translate-nl($translate-nl // $!translate-nl));
if nqp::iscont(fd-vow) {
if nqp::isrwcont(fd-vow) {
my $native-descriptor := Promise.new;
fd-vow = $native-descriptor.vow;
Pipe.new(sup.Supply.Tappable, $native-descriptor, |self!pipe-cbs(permit-channel))
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Regex.pm6
Expand Up @@ -30,7 +30,7 @@ my class Regex { # declared in BOOTSTRAP
nqp::ctxcallerskipthunks(nqp::ctx()),
'$/'
);
nqp::iscont($slash)
nqp::isrwcont($slash)
?? nqp::decont($slash = SELF!ACCEPTS-Any(topic))
!! SELF!ACCEPTS-Any(topic)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/traits.pm6
Expand Up @@ -130,7 +130,7 @@ multi sub trait_mod:<is>(Attribute:D $attr, :$required!) {
}
multi sub trait_mod:<is>(Attribute:D $attr, Mu :$default!) {
$attr.container_descriptor.set_default(nqp::decont($default));
$attr.container = nqp::decont($default) if nqp::iscont($attr.container);
$attr.container = nqp::decont($default) if nqp::isrwcont($attr.container);
}
multi sub trait_mod:<is>(Attribute:D $attr, :box_target($)!) {
$attr.set_box_target();
Expand Down

0 comments on commit 90d876a

Please sign in to comment.