core: close the compile-path gaps that broke uberscripting Selmer + config

Loading these libs via require worked (load-ns-source interprets, macros
expand lazily) but the same code inlined by uberscript routes through
eval-toplevel and compiled, surfacing four gaps:

- a ^{:map} metadata def name reads as (def (with-meta name m) v); the
  analyzer died extracting the name (config.core's defonce env). It now
  throws uncompilable so the interpreter, which handles it, takes over.
- declare was a no-op, so a compiled forward reference to a declared
  name that collides with a janet root binding bound to the host fn
  (selmer.parser's (declare parse) compiled to janet's 1-arg parse).
  declare now expands to no-init defs, the interpreter interns them,
  and the analyzer routes no-init def to the interpreter.
- class? was missing (selmer.util's exception macro calls it at
  expansion time). Always false, like ratio? — no Class objects here.
- require of an unlocatable namespace silently left an empty ns behind,
  deferring the failure to an unresolved symbol far from the cause. It
  now throws like Clojure's FileNotFoundException. Namespaces entered
  in-session count as loaded (Clojure puts them in *loaded-libs*), and
  the SCI bootstrap opts out via :lenient-require? since its
  clj-targeted requires can't all exist on this host.
This commit is contained in:
Yogthos 2026-06-11 01:31:50 -04:00
parent c2511fee7e
commit 703a59d40b
10 changed files with 127 additions and 34 deletions

View file

@ -83,6 +83,9 @@
;; Jolt has no ratio or bigdecimal types, so these are constants / reduce to int?.
(defn ratio? [x] false)
(defn decimal? [x] false)
;; No first-class Class objects either: class names are symbols the evaluator
;; handles in instance?/new positions, never values — so nothing is a class.
(defn class? [x] false)
(defn rational? [x] (int? x))
(defn nat-int? [x] (and (int? x) (>= x 0)))
(defn neg-int? [x] (and (int? x) (neg? x)))