Skip to content

Use a mutable output buffer for Punycode encoding - #34

Merged
knu merged 1 commit into
knu:masterfrom
OskarEichler:codex/mutable-punycode-output
Aug 30, 2026
Merged

Use a mutable output buffer for Punycode encoding#34
knu merged 1 commit into
knu:masterfrom
OskarEichler:codex/mutable-punycode-output

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Initialize the Punycode encoder's output as an explicitly mutable string. Fixes #31 without changing encoding behavior or enabling frozen literals throughout the library.

Reproduction and verification

Ruby 4.0.6 with -W:deprecated reports that the output string literal will be frozen when encoding bücher. With --enable=frozen-string-literal, the same call raises FrozenError while appending the first basic code point.

After the change:

  • The same -W:deprecated invocation produces the expected bcher-kva without a warning.
  • Five encode/decode round trips pass with frozen literals enabled: ASCII, empty, mixed ASCII/Unicode, German and Japanese inputs.
  • Existing rake test: 11 tests, 642 assertions, zero failures/errors on Ruby 4.0.6.
  • Ruby syntax and git diff --check pass. The gem already requires Ruby >= 2.7, which supports unary String#+.

No repository tests were added or changed because this contribution's task explicitly prohibits test-file changes. Focused checks are external invocations; older Ruby versions and upstream CI remain unverified locally.

Compatibility / breaking changes

None intended. Encoded output, return type, dependencies and Ruby requirement are unchanged. Only the encoder's local output-buffer mutability is made explicit.

@mergify

mergify Bot commented Aug 27, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@knu
knu merged commit 54477ca into knu:master Aug 30, 2026
2 checks passed
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.

Ruby 3.4.1 -- warning: literal string will be frozen in the future

2 participants