Skip to content

change: raise on invalid input in remaining builtins (silent-tolerance batch-2b)#515

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix/silent-tolerance-batch-2b
Jul 9, 2026
Merged

change: raise on invalid input in remaining builtins (silent-tolerance batch-2b)#515
InauguralPhysicist merged 1 commit into
mainfrom
fix/silent-tolerance-batch-2b

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

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

Issue Builtin Bad input Was Now
#508 len no-length type (num/fn/null) silent 0 type_mismatch
#506 append non-list target (incl. append of xs #405 footgun) silent no-op type_mismatch
#500 regex_match/find/replace invalid pattern; non-string [] / unchanged value; type_mismatch
#504 substr negative start flat clamp-to-0 counts from end (matches char_at/[])
#503 list_truncate negative length silently empties list value
#507 json_path empty path segment (.., leading/trailing .) silently skipped by strtok value (genuine miss still "")

substr is a consistency fix, not a raise: char_at and [] already count negatives from the end, and substr was the odd one out.

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. (Verified and short-circuits, so the stdlib's x != null and len of x guards never hit the new len-of-null raise.)

Tests

Suite section [116] extended — test_raise_on_bad_input.eigs, now 35 checks.

  • Release suite: 2660/2660
  • ASan + detect_leaks=1: 2660/2660, leak tally 0

Remaining 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

…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>
@InauguralPhysicist InauguralPhysicist merged commit 315f71d into main Jul 9, 2026
17 checks passed
@InauguralPhysicist InauguralPhysicist deleted the fix/silent-tolerance-batch-2b branch July 9, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment