Repository navigation
fix: preserve explicit string search positions - #232
Conversation
Model explicit integer search positions instead of dropping them, and reject unsupported positional indexOf in Lean. Cover source behavior, emission, clamping, and real Dafny postconditions.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
The compatible case-study update is ready in midspiral/balanced-match-lemmascript#1. Against this PR's current compiler commit To exercise the existing staging override, please create branch |
|
Thanks for all your contributions. I appreciate that they were well-organized and clear-cut. Happy to see more contributions from you! |
|
Thank you for reviewing and merging these contributions. I’ve opened two focused follow-ups: #233 rejects unsupported |
The Dafny emitter drops the position argument of
includes,startsWith, andendsWith. For example, TypeScript's"a".includes("a", 1)is false, while its current model searches from zero. ExplicitindexOfpositions above the string length also return-1for an empty needle instead of the string length. The Lean emitter silently drops a positionalindexOfargument even though this form is documented as unsupported.Preserve the Dafny positions, clamp integer bounds to the string length, and reject positional
indexOfin Lean. Default-position emission stays unchanged. Add executable TypeScript controls, emitter regressions, a real Dafny fixture, and document the backend behavior.Validation on main
b9c8f65: the new regression suite fails three tests, and the unchanged model verifies three reversed postconditions that disagree with TypeScript execution. With the fix, all 297 unit tests and the fixture suite pass, the correct Dafny postconditions verify, both regeneration checks produce no generated-file drift, and the Lean build passes all 1,129 jobs. An additional compiled-Dafny differential run agrees with JavaScript for 700 results across search methods, bounds, empty strings, and needles.The follow-up emits only the search helpers a program uses. The compatible balanced-match artifacts are in midspiral/balanced-match-lemmascript#1: 2,255 Dafny obligations verify with zero errors, all 19 package tests and the typecheck pass, and the original method contract is unchanged. Integration CI needs the upstream case-study staging ref described there.