#243 image save index-encodes keyword home-pkg — restored keywords fail keywordp, baked defmethod records NIL qualifiers on build/funcl

closed
Opened by atgreen

Fifth domino on the asdf operate chain (after #239/#240/#241/#242).

Symptom: on build/funcl every (defmethod ...) registered at the REPL/load records qualifier NIL — macroexpand-1 shows (MC-RECORD-METHOD ... (QUOTE NIL) ...) where (QUOTE :PRIMARY) belongs — so mc-qual-fns finds no :primary methods and every generic call raises no-applicable-method (asdf's find-component during register-preloaded-system, the whole operate chain). Direct (mc-record-method 'g (list 'integer) :primary fn) + mc-dispatch works, and an identical macro DEFINED AT THE REPL expands correctly — only the BAKED defmethod's restored body misbehaves.

Root: the baked macro table's body atoms are image-restored records. The image encoder serialized a symbol's home-pkg via ag-image-encode-heap-slot (symbol-package obj) — an INDEX ref to the live session's KEYWORD package cons — so the restore materialized a COPY of the package, and restored keyword records carry home-pkg != +primordial-keyword-pkg-tagged+. They fail keywordp AND ag-keyword-symbol-p, so the hosted expander compiles the body literal :PRIMARY as a plain-symbol VARIABLE read -> unbound -> NIL. (The canonicalizer's cave#155 keyword arm never fires either: it keys on pkg-ref == primordial tag, and :PRIMARY has no baked static keyword record to canonicalize to anyway.)

Fix: encoder-side — a keyword's home-pkg serializes as the RAW +primordial-keyword-pkg-tagged+ (lowtag 1, distinct from index lowtag 4, passes decode verbatim; exactly what the canonicalizer keys on). Restored keywords then classify correctly everywhere; qualifier matching is name-based (mc-name-same-p) so no further identity requirement.

Also noted while probing (separate, non-fatal): (symbolp name) in the defmethod expander evaluates NIL even on the hosted REPL path, so the cave#232 (declaim (notinline ...)) arm is silently dropped — worth its own look.

Comments (1)

atgreen3992410505

Fixed in 10fc0eb (three parts: keyword home-pkg raw tag via ag-keyword-symbol-p guard, decoder arm for it, raw lowtag-2 code pointers for anonymous method lambdas). defmethod now expands with (QUOTE :PRIMARY) and dispatches on build/funcl incl. :around/call-next-method. Suite 8/8, hosted 42, fixed point. Residual keywordp-on-restored-data reads NIL via the table-based path (compiler-facing ag-keyword-symbol-p is correct) — minor, noting here. Next operate-chain blocker filed separately.