errors: unresolved symbols error with Clojure's message (jolt-2o7.3)
A typo'd symbol used to auto-intern an unbound var and die later as
'Cannot call nil as a function' with no hint which symbol. Now:
$ jolt -e '(undefined-fn 1)'
Error: Unable to resolve symbol: undefined-fn in this context
The analyzer's :unresolved fallthrough now punts to the interpreter
(whose resolver raises the message above when the form runs) instead of
emitting a var-ref that interned the var. A punt rather than a hard
throw because runtime-interning forms (defmulti's setup) legitimately
reference the var they're about to create from a nested do.
Pulling that thread surfaced three real bugs the leniency was masking:
- h-resolve-global resolved unqualified symbols against ctx-current-ns,
which during analysis is jolt.analyzer — so user-ns vars NEVER
resolved through it; the lenient arm happened to emit the right ns.
Now resolves against the compile ns like the qualified branch.
- Top-level (do ...) wasn't split: Clojure compiles and EVALS each
child in sequence so earlier children's runtime effects (defmulti's
intern) are visible while later children compile. eval-toplevel now
splits.
- The stdlib itself had forward references the auto-intern hid:
10-seq's transducers used vreset!/vswap! from 20-coll (moved to
10-seq); in 20-coll qualified-ident?/realized?/list*/underive
referenced defs declared later in the file (reordered); sorted? and
partition-all are genuinely later-tier and got (declare ...).
Test rows updated where they encoded the old leniency: ir-passes'
dead-branch row (unresolved in a dead branch is an error, as in
Clojure), compile-mode's ctx-isolation row (other ctx now errors
instead of reading nil), cli rows assert the new message. Gate green,
conformance 335/335 x3, suite 4718 steady, bench within noise.
This commit is contained in:
parent
3fd0af33b6
commit
c230e70ed7
9 changed files with 133 additions and 64 deletions
|
|
@ -199,7 +199,17 @@
|
|||
(case (:kind r)
|
||||
:var (var-ref (:ns r) (:name r))
|
||||
:host (host-ref (:name r))
|
||||
(var-ref (compile-ns ctx) nm))))))
|
||||
;; :unresolved — previously emitted a var-ref that auto-interned
|
||||
;; an UNBOUND var, so a typo'd symbol died later as 'Cannot call
|
||||
;; nil as a function' with no hint which symbol (jolt-2o7.3).
|
||||
;; Punt to the interpreter: its resolver raises Clojure's
|
||||
;; 'Unable to resolve symbol' when the form actually runs (at
|
||||
;; eval for top-level forms, at call for fn bodies). A punt
|
||||
;; rather than a hard throw because runtime-interning forms
|
||||
;; (defmulti's setup call) legitimately reference the var they
|
||||
;; are about to create when nested in a non-top-level do. Real
|
||||
;; forward references want (declare ...), as in Clojure.
|
||||
(uncompilable (str "Unable to resolve symbol: " nm " in this context")))))))
|
||||
|
||||
(defn- analyze-list [ctx form env]
|
||||
(let [items (vec (form-elements form))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue