Document resyntax/grimoire/string-replacement#790
Draft
jackfirth wants to merge 4 commits into
Draft
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The string-too-short error in string-replacement-render was reported under the name string-apply-replacement, a copy-paste slip. Additionally, a replacement's required length now accounts for its end position, not just the positions its copied pieces refer to. Applying a replacement to a string shorter than the replaced region previously skipped the friendly error and failed inside make-string with a confusing contract violation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
The pieces making up a string replacement's contents are now called string pieces, with a string-piece struct supertype underneath both kinds and a public string-piece? predicate. The pieces aren't exclusively tied to replacements --- syntax-replacement uses their spans directly when narrowing replacement focus --- so the replacement-string-span operation is now string-piece-span, and contracts say string-piece? instead of enumerating the two kinds. Also converts copied-string from define-tuple-type to a plain struct, matching inserted-string. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
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.
Continues the grimoire documentation effort (#785, #787, #789) by documenting the string replacement API — the lowest-level form that Resyntax's suggestions take before being written to files.
Three commits:
resyntax/private/string-replacementmoves into theresyntax/grimoirecollection, with requires updated in its five users.equal?consequences, half-open zero-based positions, and a cross-reference tying copied pieces to the formatting-preservation mechanism documented in the syntax paths section.string-replacement-renderreported its errors under the namestring-apply-replacement, andrequired-lengthdidn't account for the#:endposition, so applying a replacement to a string shorter than its replaced region died insidemake-stringinstead of raising the friendly contract error. Both have regression tests.One known design wart deliberately left alone for now:
union-into-string-replacementreduces from an empty replacement at position 0, so reducing even a single replacement produces a structurally different (though behaviorally equivalent) replacement, and the union operation has no identity element up toequal?— unlike source groups. Documented as-is; deciding whether to rework it is future work.🤖 Generated with Claude Code