Skip to content

fix for pretty_generate throwing wrong number of arguments error #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

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 force-pushed the bugfix/pretty_generate branch from 8be4b8e to 8433571 Compare May 16, 2025 16:16
@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