THRIFT-6104: Accept Ruby Set subclasses in native struct writing#3645
Merged
Conversation
Client: rb Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the Ruby native struct writer’s handling of Thrift set fields with Ruby’s Set contract by accepting Set subclasses (previously rejected by a strict class check). This brings behavior in line with the pure-Ruby writer and avoids incorrectly routing Set subclasses through Hash handling.
Changes:
- Update native
TTYPE_SETserialization to treat anySetsubclass as aSetviarb_obj_is_kind_of. - Add an RSpec example ensuring a
Setsubclass serializes identically to an equivalentSet.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/rb/spec/struct_spec.rb | Adds a regression spec asserting Set subclasses serialize like Set. |
| lib/rb/ext/struct.c | Changes native set-container detection from exact-class match to kind_of?(Set) semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The native struct writer checked for the exact
Setclass when serializing Thriftsetfields. ASetsubclass was therefore routed to Hash handling and rejected, while the pure-Ruby writer accepted and serialized the same value.The native writer now honors the public
Setcontract, allowing subclasses to serialize the same elements as an equivalentSet.[skip ci]anywhere in the commit message to free up build resources.