Skip to content
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

Fix Regex#inspect with non-literal-compatible options #14575

Merged

Conversation

straight-shoota
Copy link
Member

With this patch Regex#inspect only uses the literal syntax when all option flags can be represented. If options includes additional flags, it uses a more extensive representation based on the constructor form.

I'm not sure if the helper methods #inspect_literal and #inspect_extensive should really be exposed. I can't see any specific use case for calling them directly instead of #inspect. We could make them private and move all documentation to #inspect.

Resolves #14530

@straight-shoota straight-shoota added this to the 1.13.0 milestone May 10, 2024
Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have #inspect_literal and #inspect_extensive be private, and only document that #inspect will usually generate a literal expression but may generate an explicit Regex.new expression when some flags are set; but otherwise 👍

@straight-shoota straight-shoota merged commit 453a159 into crystal-lang:master May 15, 2024
58 of 61 checks passed
@straight-shoota straight-shoota deleted the fix/regex-inspect branch May 15, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regex#inspect does not show all flags
3 participants