mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
vm.c: allow Hash subclasses to override []; close #6675
The OP_GETIDX optimization now only applies to instances of the Hash class itself. Subclasses fall back to method dispatch, allowing them to override the [] method. This fixes compatibility with libraries like mruby-hashie that rely on aliasing/overriding [] in subclasses. Trade-off: Hash#[] cannot be overridden on the Hash class itself (only on subclasses). This is a reasonable semantic for mruby since subclassing is the proper pattern for customization. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Reference in New Issue
Block a user