Uh oh!
There was an error while loading. Please reload this page.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I added the implementation, now I'm just not sure what is the best way to check for builtin Set. I could check
RUBY_VERSION >= "3.5"but I don't know if that may cause issues with JRuby / Truffle ruby?I could check if
Set#initializehas a source_location, but then what if someone decorated it?Etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check if it has a
hashivarThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
if Set.new.instance_variable_get(:@hash), but I think JRuby might not like it because they already move Set into a core class a long time ago.So perhaps I should check with
Pysch.load(Pysch.dump(Set.new([1, 2]))). I'll sleep on it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a broader question is: why not move to a more general-purpose implementation completely? Have the behavior change (looks like a set -> doesn't look like a set) after 3.5. Does inter-version consistency matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does. Many shops (including Shopify) have Psych-serialized data in their databases that they expect to be able to deserialize, so the format should match. Similarly, we might need to roll-back Ruby and/or gem versions, and that should not result in the - now new - format in the database being unreadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, another silly question: I tested psych with the new Set implementation and it passes all tests on Ruby HEAD and with psych HEAD. What new test should I be messing around with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's an internal implementation