Repository navigation
fix(require): a missing namespace raises FileNotFoundException - #141
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
…-ns-file-not-found
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
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.
Refs #137 (the
FileNotFoundExceptionitem; the other items of that issue are not in this PR).The defect
(require 'no.such.ns)raisedlib_not_foundas a name error, which is aRuntimeException. The JVM raisesjava.io.FileNotFoundException, and portable code relies on that to detect an optional namespace:On cljw that catch never matched.
The fix
lib_not_foundhas kindfile_not_found. The catch above matches;IOExceptionandExceptionstill match through the supertype chain. The message is unchanged. The uncaught report is headed "File not found" where it was "Name error".aliasandreferraised the same code for a namespace that is not loaded, although they look for no file. They now raisenamespace_unknown("No namespace"), as on the JVM.narrowCallFnErrorpassesFileNotFoundthrough, so arequireorslurpthat fails while a macro expands stays catchable instead of becoming an internal error.Behaviour change to note
Code that caught the missing-namespace error as
RuntimeExceptionno longer catches it (FileNotFoundExceptionis not aRuntimeException). That is the JVM behaviour.Checks
Built with
zig build -Dwasm -Doptimize=ReleaseSafe(Zig 0.16.0):test/clj/run_suites.clj: 171 suites loaded, 1001 tests, 5397 assertions, 0 failures, 0 errorsscripts/corpus_regression.clj: 5515 of 5515 golden outputs reproducedtest/e2e/phase6_16_b_4_require_basic.sh(updated for the new kind label),phase6_16_b_4_require_libspec.sh,phase15_require_fs.sh,phase14_require_idempotent.shpasszig build testandzig fmt --checkpassThe full gate (
test/run_all.sh) was not run locally.Please do not merge before release PR #138 lands. This PR, #139 and the #136 PR each add a line under Unreleased in
CHANGELOG.md, so the second and third to merge need a small conflict resolved there.