Skip to content

Ruby 3.4 frozen string literal deprecation warnings #253

@PhilMeyr

Description

@PhilMeyr

Description

When using combine_pdf with Ruby 3.4, deprecation warnings are emitted about frozen string literals.

Warning message

lib/combine_pdf/parser.rb:730: warning: string returned by :__WKANCHOR_2.to_s will be frozen in the future

Environment

  • Ruby version: 3.4.x
  • combine_pdf version: 1.0.31

Root cause

In Ruby 3.4, Symbol#to_s returns a frozen string. The code at line 730 of lib/combine_pdf/parser.rb likely modifies the result of to_s called on a symbol, which triggers this deprecation warning.

Suggested fix

When modifying a string returned by Symbol#to_s, create a mutable copy first:

# Instead of:
sym.to_s.prepend('_')

# Use:
"_#{sym}"
# or
sym.to_s.dup.prepend('_')

This is similar to the fix applied in other gems like marcel (rails/marcel#140).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions