Skip to content

fix(base): stop prefix checks at the matched prefix - #1645

Open
EpsilonPhoenix wants to merge 1 commit into
bendlang:mainfrom
EpsilonPhoenix:main
Open

EpsilonPhoenix wants to merge 1 commit into
bendlang:mainfrom
EpsilonPhoenix:main

Conversation

@EpsilonPhoenix

Copy link
Copy Markdown

Fixes #1640.

String.starts_with(s, "") previously stayed stuck when s was unknown. Matching a known prefix also unnecessarily required inspecting the remaining haystack.

Match the prefix first, returning True as soon as it is exhausted. Preserve existing signatures and short-circuit on character mismatches.

Adds proof regressions for arbitrary strings and tails, plus runtime coverage for empty strings, exact matches, longer prefixes, mismatches, and Unicode.

Validation:

  • All 36 Base tests match their expected output.
  • All five string tests pass in the interpreter, generated JavaScript, and native C.
  • BendTT validates the new regression test and existing string_contains and string_kit tests.

- Match the prefix before inspecting the remaining string
- Add coverage for empty prefixes, mismatches, and Unicode
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.

Let an empty String prefix reduce without inspecting the haystack

1 participant