Skip to content

Fix string will be frozen in the future warning (Issue #280) - #281

Open
KarlHeitmann wants to merge 1 commit into
inossidabile:masterfrom
KarlHeitmann:fix_string_returned_by_will_be_frozen_in_the_future
Open

Fix string will be frozen in the future warning (Issue #280)#281
KarlHeitmann wants to merge 1 commit into
inossidabile:masterfrom
KarlHeitmann:fix_string_returned_by_will_be_frozen_in_the_future

Conversation

@KarlHeitmann

Copy link
Copy Markdown

As described in #280 , if you use ruby 3.4 and you set the ENV var RUBYOPT="-W:deprecated" you will get a warning, because soap_action is a string literal that is mutating by the soap_action.force_encoding('UTF-8') method call.

the soap_action was in lib/wash_out/routes:60.

soap_action.keys.first will return a Symbol instance, in Ruby 4 Symbol.to_s will return a frozen string literal, so the warning is telling us when this string will become a frozen string literal in Ruby 4, this line will break.

By wrapping line 60 with String.new(...), it will take that frozen string literal and will convert it into a mutable string literal. The code will be safe.

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.

1 participant