diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-12 18:41:18 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-12 18:41:18 +0900 |
| commit | bbb088234395efda23540d30ab5d1cb40f220d82 (patch) | |
| tree | 4f66588878264c0d2a17529629d7d183d6a49d29 /mrbgems | |
| parent | d4ff92bcf65ce140495014f40d22b93a1b1fb957 (diff) | |
| download | mruby-bbb088234395efda23540d30ab5d1cb40f220d82.tar.gz mruby-bbb088234395efda23540d30ab5d1cb40f220d82.zip | |
Modifying frozen objects will raise `FrozenError`.
`FrozenError` is a subclass of `RuntimeError` which used to be
raised. [Ruby2.5]
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-string-ext/mrblib/string.rb | 6 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index cb36d9a48..0da84daed 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -95,7 +95,7 @@ class String # "hello".lstrip! #=> nil # def lstrip! - raise RuntimeError, "can't modify frozen String" if frozen? + raise FrozenError, "can't modify frozen String" if frozen? s = self.lstrip (s == self) ? nil : self.replace(s) end @@ -125,7 +125,7 @@ class String # <code>nil</code> if <i>str</i> was not altered. # def strip! - raise RuntimeError, "can't modify frozen String" if frozen? + raise FrozenError, "can't modify frozen String" if frozen? s = self.strip (s == self) ? nil : self.replace(s) end @@ -199,7 +199,7 @@ class String # string #=> "thsa sting" # def slice!(arg1, arg2=nil) - raise RuntimeError, "can't modify frozen String" if frozen? + raise FrozenError, "can't modify frozen String" if frozen? raise "wrong number of arguments (for 1..2)" if arg1.nil? && arg2.nil? if !arg1.nil? && !arg2.nil? diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 8de4b6c52..adeb09bc1 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -89,7 +89,7 @@ static void mrb_struct_modify(mrb_state *mrb, mrb_value strct) { if (MRB_FROZEN_P(mrb_basic_ptr(strct))) { - mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen struct"); + mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen struct"); } mrb_write_barrier(mrb, mrb_basic_ptr(strct)); |
