Skip to content

Conversation

@CodyBriscoe
Copy link

Found this error to first appear in 2.11.0 as a breaking change in one of our codebases.

When State === opts is false, pretty_generate would eventually call generate with 3 arguments:
State.generate(obj, options, nil)

However if State === opts, it would originally try to call state.generate(obj) with only one argument. However, state just returns the State class itself JSON::Ext::Generator::State and expects 3 arguments.

This change aligns the behavior with the regular JSON.generate method to call opts.generate instead.

@byroot
Copy link
Member

byroot commented May 16, 2025

Oh, that's a dumb mistake. Could you add a regression test?

I can release the fix quickly.

@CodyBriscoe
Copy link
Author

Sure thing, will have that up in a moment

@CodyBriscoe
Copy link
Author

@byroot let me know if you want anything tweaked or added

@byroot byroot merged commit ddfe6f4 into ruby:master May 16, 2025
@CodyBriscoe CodyBriscoe deleted the bugfix/pretty_generate branch May 16, 2025 16:18
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.

2 participants