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

Flag files that modify string literals #85

Merged
merged 1 commit into from Feb 6, 2022

Conversation

danielmorrison
Copy link
Contributor

When running in an environment that freezes string literals by default, hybi.rb raises exceptions as it modifies the format = 'C2' string (line 224).

Adding the magic comment supports this use case without modifying behavior for anyone else. I added it to one spec too, so that running specs this way (RUBYOPT="--enable=frozen-string-literal" rspec) keeps them all passing.

When running in an environment that freezes string literals by default, `hybi.rb` raises exceptions as it modifies the `'C2'` string.

Adding the magic comment supports this use case without modifying behavior for anyone else. I added it to one spec too, so that running specs this way (`RUBYOPT="--enable=frozen-string-literal" rspec`) keeps them all passing.
@jcoglan jcoglan merged commit 4739ec9 into faye:main Feb 6, 2022
@jcoglan
Copy link
Collaborator

jcoglan commented Feb 6, 2022

Thank you @danielmorrison :)

@jcoglan
Copy link
Collaborator

jcoglan commented Feb 6, 2022

Out of curiosity, would it also work for you if this library didn't use bare string literals but used new string objects, i.e. String.new("literal data")?

@danielmorrison
Copy link
Contributor Author

Out of curiosity, would it also work for you if this library didn't use bare string literals but used new string objects, i.e. String.new("literal data")?

It would. I tried to pick the least-invasive syntax to avoid any bike shedding.

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.

None yet

2 participants