change: raise on invalid input in remaining builtins (silent-tolerance batch-2b)#515
Merged
Merged
Conversation
…e batch-2b) Continues the silent-tolerance audit (#490–#512). The remaining builtins in the "bad input folds to a silent sentinel" class now raise or (where the bug is an inconsistency) align with the [] operator: - len (#508): a value with no length (number, fn, null, ...) raises type_mismatch instead of folding to 0. Guarded callers use `x != null and len of x`, and `and` short-circuits, so the guarded len is never reached. - append (#506): a non-list target — including the `append of xs` #405 arg-vector footgun — raises type_mismatch instead of a silent no-op. - regex_match/regex_find/regex_replace (#500): an invalid pattern raises value (was [] / input-unchanged, indistinguishable from a clean no-match); a non-string operand raises type_mismatch. - substr (#504): a negative start counts from the end, matching char_at and [] (was a flat clamp-to-0 — an inconsistency, not a raise). - list_truncate (#503): a negative length raises value instead of silently emptying the list. - json_path (#507): an empty path segment (leading/trailing dot or ..) raises value instead of being silently skipped by strtok; a genuine lookup miss still returns "". Load-bearing check: the only reliance was test_list_truncate T4 (asserted the negative-clamps-to-0 behavior) — updated to assert the raise. len, append, regex, substr and json_path broke zero existing tests. Regression: suite section [116] extended (test_raise_on_bad_input.eigs, now 35 checks). Release + ASan/leak suites green (2660/2660, leak tally 0). Closes #500 Closes #503 Closes #504 Closes #506 Closes #507 Closes #508 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 silent-tolerance audit (#490–#512). The remaining builtins in the "bad input folds to a silent sentinel" class now raise — or, where the bug is an inconsistency rather than tolerance, align with the
[]operator.Changes
lennull)0type_mismatchappendappend of xs#405 footgun)type_mismatchregex_match/find/replace[]/ unchangedvalue;type_mismatchsubstrchar_at/[])list_truncatevaluejson_path.., leading/trailing.)strtokvalue(genuine miss still"")substris a consistency fix, not a raise:char_atand[]already count negatives from the end, andsubstrwas the odd one out.Load-bearing check
The only reliance was
test_list_truncateT4 (asserted the negative-clamps-to-0 behavior) — updated to assert the raise.len,append,regex,substr, andjson_pathbroke zero existing tests. (Verifiedandshort-circuits, so the stdlib'sx != null and len of xguards never hit the newlen-of-null raise.)Tests
Suite section [116] extended —
test_raise_on_bad_input.eigs, now 35 checks.detect_leaks=1: 2660/2660, leak tally 0Remaining from the audit (separate focused PRs)
Each a different subsystem, deliberately not bundled: #495 json_decode strictness (JSON-parser rework), #494 parser missing-expr-after-
is/of(expression parser), #491 for-in live-length (VM loop lowering). Plus docs #492.Closes #500
Closes #503
Closes #504
Closes #506
Closes #507
Closes #508
🤖 Generated with Claude Code