aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-04-06 00:02:11 -0700
committerJeremy Evans <code@jeremyevans.net>2019-05-26 11:09:21 -0700
commit39eadca76b48fc7841da688f6745e40897ec37ff (patch)
tree5c29107b29f5384eedb390af636186e7877369f3 /thread.c
parent897901283c79e5f5f33656abdd453dc272268748 (diff)
downloadruby-39eadca76b48fc7841da688f6745e40897ec37ff.tar.gz
Add FrozenError#receiver
Similar to NameError#receiver, this returns the object on which the modification was attempted. This is useful as it can pinpoint exactly what is frozen. In many cases when a FrozenError is raised, you cannot determine from the context which object is frozen that you attempted to modify. Users of the current rb_error_frozen C function will have to switch to using rb_error_frozen_object or the new rb_frozen_error_raise in order to set the receiver of the FrozenError. To allow the receiver to be set from Ruby, support an optional second argument to FrozenError#initialize. Implements [Feature #15751]
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index e88ed87306..d4f33a2e42 100644
--- a/thread.c
+++ b/thread.c
@@ -3325,7 +3325,7 @@ VALUE
rb_thread_local_aset(VALUE thread, ID id, VALUE val)
{
if (OBJ_FROZEN(thread)) {
- rb_error_frozen("thread locals");
+ rb_frozen_error_raise(thread, "can't modify frozen thread locals");
}
return threadptr_local_aset(rb_thread_ptr(thread), id, val);
@@ -3402,7 +3402,7 @@ rb_thread_variable_set(VALUE thread, VALUE id, VALUE val)
VALUE locals;
if (OBJ_FROZEN(thread)) {
- rb_error_frozen("thread locals");
+ rb_frozen_error_raise(thread, "can't modify frozen thread locals");
}
locals = rb_ivar_get(thread, id_locals);