fix(data): correct TOON escape decoding and double-hashing step for MIN_VALUE - #369
Merged
Conversation
…IN_VALUE Two latent correctness bugs in the data module: - ToonSyntax.processEscapeSequences decoded escapes with a chain of String.replace calls whose order let an already-unescaped backslash be reinterpreted: a value such as "a\\nb" (escaped backslash + literal n) wrongly became a newline instead of a backslash followed by n. Replace the chained substitutions with a single left-to-right pass that consumes each escape exactly once and leaves unknown escapes untouched. - DoubleHashing.probe derived the probe step from Math.abs(hashCode), which stays negative for Integer.MIN_VALUE and produced a non-positive step that folded the probe sequence onto a subset of slots (e.g. 12 of 13 on a prime-sized table). Use Math.abs(hashCode % (length - 1)), which is identical for every other hashCode but overflow-safe for MIN_VALUE. Add regression tests for both. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PUdwoDrPdkLATaTkPcnpm3
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.
Two latent correctness bugs in the data module:
ToonSyntax.processEscapeSequences decoded escapes with a chain of
String.replace calls whose order let an already-unescaped backslash be
reinterpreted: a value such as "a\nb" (escaped backslash + literal n)
wrongly became a newline instead of a backslash followed by n. Replace
the chained substitutions with a single left-to-right pass that consumes
each escape exactly once and leaves unknown escapes untouched.
DoubleHashing.probe derived the probe step from Math.abs(hashCode), which
stays negative for Integer.MIN_VALUE and produced a non-positive step that
folded the probe sequence onto a subset of slots (e.g. 12 of 13 on a
prime-sized table). Use Math.abs(hashCode % (length - 1)), which is
identical for every other hashCode but overflow-safe for MIN_VALUE.
Add regression tests for both.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01PUdwoDrPdkLATaTkPcnpm3