Explicitly freeze concatenated-String constants to unbreak on non-main Ractors. - #449
Merged
sporkmonger merged 4 commits intoJul 30, 2022
Merged
Conversation
houndci-bot
reviewed
Jan 15, 2022
Collaborator
Well, it also needs to work. Did you not try out your change? :) irb(main):001:0> FOO = "this is foo"
=> "this is foo"
irb(main):002:0> %q{FOO}
=> "FOO"
irb(main):003:0> %q{#{FOO}}
=> "\#{FOO}"I guess you wanted but I think |
okeeblow
force-pushed
the
freeze_concatenated_strings
branch
from
January 15, 2022 21:04
37d2285 to
0f5c03d
Compare
Contributor
Author
|
Sure, that syntax is fine. I just want this gem to stop blowing up my entire app :) |
Collaborator
|
Can you add a test too? |
okeeblow
force-pushed
the
freeze_concatenated_strings
branch
from
January 22, 2022 22:29
0f5c03d to
6390312
Compare
houndci-bot
reviewed
Jan 22, 2022
Collaborator
|
Can you resolve the conflict? |
dentarg
reviewed
Jan 22, 2022
okeeblow
force-pushed
the
freeze_concatenated_strings
branch
from
January 23, 2022 01:02
6390312 to
178bcd9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When building
Strings with theString#concat/String#+methods, the receiver and argumentStrings are literals, but the resulting value is not, so they are left unfrozen when we rely only on thefrozen_string_literaldirective.Switch to the
%qnon-interpolableStringliteral syntax for these because it feels less gross to me than e.g.HOST = (UNRESERVED + SUB_DELIMS + "\\[\\:\\]").freeze. This syntax was present in Ruby 2.0, which is Addressable's minimum requirement :)Before
Concatenated
Strings are not frozen when thefrozen_string_literal: truedirective is used.…and we encounter a
Ractor::IsolationErrorwhen trying to useAddressable::URI::parsein a non-mainRactor:After
Strings are frozen, and Addressable can be used in a non-mainRactor:Even though
Ractor::shareable?still returnsfalsehere, the Ractor "shareable objects" docs say frozenStringobjects are shareable. We could additionally callRactor::make_shareable, but there seems to be no reason to since it does work: