Skip to content

Commit 3a4c3fd

Browse files
committedOct 15, 2015
Merge branch '2.2' into fix-process-spawn
* 2.2: allow nil,true,false to be modified when frozen
2 parents 29674df + a2d76f5 commit 3a4c3fd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎vm/builtin/access_variable.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace rubinius {
4949

5050
Object* recv = args.recv();
5151

52-
if(CBOOL(recv->frozen_p(state))) {
52+
if(CBOOL(recv->frozen_p(state)) && CBOOL(recv->frozen_mod_disallowed(state))) {
5353
Exception::frozen_error(state, call_frame, recv);
5454
return 0;
5555
}
@@ -66,7 +66,7 @@ namespace rubinius {
6666

6767
/* The writer case. */
6868
if(access->write()->true_p()) {
69-
if(CBOOL(self->frozen_p(state))) {
69+
if(CBOOL(self->frozen_p(state)) && CBOOL(self->frozen_mod_disallowed(state))) {
7070
Exception::frozen_error(state, call_frame, self);
7171
return 0;
7272
}

‎vm/builtin/object.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,17 @@ namespace rubinius {
183183
}
184184

185185
void Object::check_frozen(STATE) {
186-
if(CBOOL(frozen_p(state))) {
186+
if(CBOOL(frozen_p(state)) && CBOOL(frozen_mod_disallowed(state))) {
187187
Exception::frozen_error(state, this);
188188
}
189189
}
190+
191+
Object* Object::frozen_mod_disallowed(STATE) {
192+
if(this->nil_p() || this->true_p() || this->false_p()) {
193+
return cFalse;
194+
}
195+
return cTrue;
196+
}
190197

191198
Object* Object::get_field(STATE, size_t index) {
192199
return type_info(state)->get_field(state, this, index);

‎vm/builtin/object.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ namespace rubinius {
390390
* Similar to CRuby rb_check_frozen
391391
*/
392392
void check_frozen(STATE);
393+
394+
/**
395+
* Returns true unless one of the objects is nil, true, or
396+
* false. Those objects are allowed to be modified when
397+
* frozen.
398+
*/
399+
Object* frozen_mod_disallowed(STATE);
393400

394401
public: /* accessors */
395402

0 commit comments

Comments
 (0)
Please sign in to comment.