Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make Set/Bag.delete throw X::Immutable

  • Loading branch information...
commit 95b45b4bb14166b845023ebf9bf0d4599a69fd9e 1 parent 74c0916
@lizmat lizmat authored
Showing with 10 additions and 2 deletions.
  1. +1 −1  src/core/Bag.pm
  2. +8 −0 src/core/Exception.pm
  3. +1 −1  src/core/Set.pm
View
2  src/core/Bag.pm
@@ -53,7 +53,7 @@ my class Bag is Iterable does Associative does Baggy {
method elems returns Int { [+] self.values }
method exists($a) returns Bool { %!elems.exists($a) }
method delete($a) is hidden_from_backtrace {
- X::Method::NotFound.new( method => 'delete', typename => self.^name ).throw;
+ X::Immutable.new( method => 'delete', typename => self.^name ).throw;
}
method Bool { %!elems.Bool }
method Numeric { self.elems }
View
8 src/core/Exception.pm
@@ -1189,6 +1189,14 @@ my class X::Assignment::RO is Exception {
}
}
+my class X::Immutable is Exception {
+ has $.typename;
+ has $.method;
+ method message {
+ "Cannot call '$.method' on an immutable '$.typename'";
+ }
+}
+
my class X::NoDispatcher is Exception {
has $.redispatcher;
method message() {
View
2  src/core/Set.pm
@@ -175,7 +175,7 @@ my class Set is Iterable does Associative {
method elems returns Int { %!elems.elems }
method exists($a) returns Bool { %!elems.exists($a) }
method delete($a) is hidden_from_backtrace {
- X::Method::NotFound.new( method => 'delete', typename => self.^name ).throw;
+ X::Immutable.new( method => 'delete', typename => self.^name ).throw;
}
method Bool { %!elems.Bool }
method Numeric { %!elems.Numeric }
Please sign in to comment.
Something went wrong with that request. Please try again.