Repository navigation
fix(regex): a declined construct in a runtime pattern is catchable - #142
Merged
Merged
Conversation
`(require 'no.such.ns)` raised lib_not_found as a name error, which is a
RuntimeException. The JVM raises java.io.FileNotFoundException, and
portable code relies on that to detect an optional namespace:
(try (require 'x) (catch java.io.FileNotFoundException _ ...))
lib_not_found now has kind file_not_found, so that catch matches, and
IOException and Exception still do through the supertype chain. The
message is unchanged; the uncaught report is headed "File not found".
`alias` and `refer` raised the same code for a namespace that is not
loaded, although they look for no file. They now raise namespace_unknown
("No namespace"), as on the JVM.
narrowCallFnError passes FileNotFound through, so a `require` or `slurp`
that fails while a macro expands stays catchable instead of becoming an
internal error.
Refs #137
A pattern that uses a construct cljw declines (a backreference, an unsupported inline flag or class form) raised the uncatchable feature_not_supported error from every surface, so `re-pattern` on one bad string ended the process even inside (try ... (catch Throwable ...)). A server that takes patterns from clients could not refuse one. A pattern built from a runtime string is data. It now raises the new catalog code regex_construct_not_supported, kind value_error: a catchable IllegalArgumentException whose message still names the construct. This covers re-pattern, Pattern/compile and the String regex methods, which all go through regex_value.raiseCompileError. A #"..." literal is code. The analyzer calls the new raiseLiteralCompileError, which keeps the uncatchable signal for a declined construct. This amends accepted divergence AD-060, by the maintainer's decision of 2026-12-01. Its entry, its check expression and its pin in test/e2e/regex_parity_gaps.sh now use the literal; the runtime half is pinned in test/clj/suites/regex_test.clj. Fixes #136
…-ns-file-not-found
…tries under Unreleased
The require of a missing namespace raises a file_not_found error, so the rendered report label changed from "Name error" to "File not found".
…g-ns-file-not-found
…untime-unsupported-catchable
BuddhiLW
added a commit
that referenced
this pull request
Dec 1, 2026
No textual conflicts. build.zig.zon takes staging's version 1.15.9 and keeps this branch's minimum_zig_version, zlinter and zwasm pins. CHANGELOG keeps staging's [1.15.9] section unchanged and its Unreleased entries; the auto-merge had folded this branch's four Zig 0.17.1 / zwasm v2.12.1 entries into [1.15.9], so they are moved back under Unreleased, since they did not ship in 1.15.9. The incoming regex (#139, #142) and require (#141) code uses no API 0.17.1 removed or deprecated, so it builds unchanged: the 0.17 rename pass over src touches nothing, `zig fmt --check` is clean, and the -Dwasm ReleaseSafe build is green. All 171 clj suites pass (1006 tests, 5420 assertions). Smell-audited: 0: merge only; build.zig.zon takes staging's version, no Zig source changed by the resolution
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.
Fixes #136. Amends accepted divergence AD-060, by the maintainer's decision of 2026-12-01.
The defect
A pattern that uses a construct cljw declines (a backreference, an unsupported inline flag or class form) raised the uncatchable
feature_not_supportederror from every surface.re-patternon one bad string ended the process, even inside(try ... (catch Throwable ...)):A server that takes patterns from clients could not refuse one. ADR-0031 names linear-time matching as what lets untrusted patterns run; an untrusted pattern that ends the host defeats that.
The decision
regex_construct_not_supported, kindvalue_error: a catchableIllegalArgumentExceptionwhose message still names the construct. This coversre-pattern,Pattern/compileand theStringregex methods; all go throughregex_value.raiseCompileError.#"..."literal is code. The analyzer calls the newraiseLiteralCompileError, which keeps the uncatchable signal for a declined construct.src/runtime/error/catalog.zigalready made the same move for malformed JSON, EDN and the STM ops.What moved with it
.dev/accepted_divergences.yaml: the AD-060 summary, example and pin state the split; its check expression uses the literal.test/e2e/regex_parity_gaps.sh: the uncatchable pin uses the literal#"(a)\1".test/clj/suites/regex_test.clj: the runtime half, throughre-pattern,Pattern/compileandString.split, plus a check that the process goes on.Checks
Built with
zig build -Dwasm -Doptimize=ReleaseSafe(Zig 0.16.0):test/clj/run_suites.clj: 171 suites loaded, 1001 tests, 5399 assertions, 0 failures, 0 errorstest/e2e/regex_parity_gaps.sh: 3 of 3scripts/check_accepted_divergences.sh: ok, 68 divergences, 60 executablescripts/corpus_regression.clj: 5515 of 5515 golden outputs reproducedzig build testandzig fmt --checkpassThe full gate (
test/run_all.sh) was not run locally.Not done
The release-wave coordinator asked for a devil's-advocate review and an ADR number for a change to a pinned divergence. The maintainer decided directly, so there is no new ADR file; the amendment is recorded in the AD-060 entry itself. Add an ADR if the project wants one.
Please do not merge before release PR #138 lands. This PR, #139 and #141 each add a line under Unreleased in
CHANGELOG.md, so the second and third to merge need a small conflict resolved there.