Skip to content

Commit

Permalink
Fixes #5160. Inconsistencies with MRI: FrozenError (can't modify froz…
Browse files Browse the repository at this point in the history
…en array)

This not only appropriately fixes array -> Array but will also appropiately
uses the metaclass so MyFoo < Array will print out the right FrozenError as
well.
  • Loading branch information
enebo committed May 9, 2018
1 parent e3ad1b2 commit a10ae0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Expand Up @@ -569,7 +569,7 @@ private RubyArray makeSharedFirst(ThreadContext context, IRubyObject num, boolea
*/
protected final void modifyCheck() {
if ((flags & TMPLOCK_OR_FROZEN_ARR_F) != 0) {
if ((flags & FROZEN_F) != 0) throw getRuntime().newFrozenError("array");
if ((flags & FROZEN_F) != 0) throw getRuntime().newFrozenError(this.getMetaClass());
if ((flags & TMPLOCK_ARR_F) != 0) throw getRuntime().newTypeError("can't modify array during iteration");
}
}
Expand Down

0 comments on commit a10ae0a

Please sign in to comment.