core: sq-symbol qualifies unresolved syms against :compile-ns, not the analyzer's ns

deftype with inline protocol methods failed in compile mode with "Unable to
resolve symbol: jolt.analyzer/extend-type". deftype's expander template emits
(extend-type ...), but extend-type is defined AFTER deftype in 30-macros — so
when the expander compiles at defmacro time, syntax-quote lowering can't
resolve it and falls through to current-ns qualification. The analyzer runs
interpreted in jolt.analyzer, so ctx-current-ns mid-compile is jolt.analyzer,
baking the wrong qualification into the compiled template.

Same bug class jolt-265 fixed for resolve-var: read :compile-ns (the namespace
being compiled) when set, falling back to ctx-current-ns. Interpret and
self-host modes never hit it (interpreted expanders resolve at use time, when
extend-type exists) — which is also why no gate test caught it: nothing
EVALUATED a deftype-with-inline-methods in compile mode. Two 3-mode
conformance cases added.

Gate: conformance 271x3, fallback-zero, fixpoint, self-host, sci, staged,
suite 4046>=4034, all specs+unit.
This commit is contained in:
Yogthos 2026-06-10 09:22:54 -04:00
parent dc57052780
commit 1675d88778
2 changed files with 14 additions and 1 deletions

View file

@ -155,7 +155,15 @@
(special-symbol? nm) form
(ns-find (ctx-find-ns ctx "clojure.core") nm)
{:jolt/type :symbol :ns "clojure.core" :name nm}
{:jolt/type :symbol :ns (ctx-current-ns ctx) :name nm}))
# Unresolved -> qualify to the namespace being COMPILED when set (the
# analyzer runs interpreted in jolt.analyzer, so ctx-current-ns is wrong
# mid-compile — the same seam resolve-var/h-current-ns use). Matters when
# a macro expander's template is lowered while a symbol it references is
# not yet defined (deftype's extend-type, defined later in the same tier):
# it must qualify to the macro's home ns, not jolt.analyzer.
{:jolt/type :symbol
:ns (or (get (ctx :env) :compile-ns) (ctx-current-ns ctx))
:name nm}))
form))
(defn- d-realize