Skip to content

Handle Struct members that override the indexing method - #96

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/struct-index-member
Open

Handle Struct members that override the indexing method#96
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/struct-index-member

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Use the core Struct index reader for members. A valid Struct member named [] overrides the reader and currently raises ArgumentError while printing.

Reproduction and verification

PP.singleline_pp(Struct.new(:[], :other).new(1, 2), String.new) raises before this patch. The corpus also covers send, class, members, size and to_a member names.

  • Isolated branch: 6 focused checks pass under rbenv Ruby 4.0.6.
  • Existing upstream RBENV_VERSION=4.0.6 rbenv exec rake test: 36 tests / 56 assertions, zero failures before and after.
  • 2,000 ordinary single-/multi-line outputs remain byte-identical.
  • Source-only change; no test files added or modified under the contributor's task constraint. Focused scripts are outside the repository. Other Ruby engines/versions and native Windows were not executed.

Breaking-change notes

No API removal. Struct member access now uses core storage even when [] is overridden, consistent with the existing core lookup for members and class. A member named [] now prints successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant