Skip to content

Converter code produces "literal string will be frozen in the future" warnings #14

@StalemateInc

Description

@StalemateInc

Greetings 👋

Running this gem produces the warnings like this one:

html2markdown/lib/html2markdown/converter.rb:54: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)

With this change in Ruby 3.4.1 all string literals behave like they are frozen (which will likely happen by default in next Ruby iterations). The solution is to either disable strings freezing on per-file basis or adjust the code to no longer produce the frozen strings where they are modified.

Steps:
To reproduce the warnings:

> bundle exec rspec --warnings

To see the failures from upcoming behaviour:

> RUBYOPT='--enable=frozen-string-literal' bundle exec rspec

Expected result: All tests pass.
Actual result: All tests fail with an errors like FrozenError: can't modify frozen String: "".

Ruby version:

> ruby -v
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-darwin22]

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