From 34cb16f6dd3c06d07f3d74b2a49aa22ed0b50bd5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 24 Jun 2026 00:13:43 -0400 Subject: fix(coverage): bind json reader vars dynamically in simplecov parsers The simplecov parse helpers let-bound json-object-type, json-array-type, and json-key-type around json-read-file to get string-keyed hash tables. Under lexical-binding the compiler hadn't seen json.el's defvars, so it compiled those as lexical bindings that never reached the reader; the compiled helpers got json.el's default symbol-keyed alist and then signaled wrong-type-argument hash-table-p in their maphash. Interpreted code happened to work because the in-function require made the vars special first. Add eval-when-compile (require 'json) so the compiler treats them as dynamic. Claude-Session: https://claude.ai/code/session_01BqrdWUo9GcznYX2pZr76gZ --- modules/coverage-core.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/coverage-core.el b/modules/coverage-core.el index 9b102bb7b..e8f7a4740 100644 --- a/modules/coverage-core.el +++ b/modules/coverage-core.el @@ -25,6 +25,15 @@ (require 'subr-x) (require 'system-lib) +;; Make json.el's reader variables visible to the byte/native compiler so the +;; `let' bindings of `json-object-type' / `json-array-type' / `json-key-type' +;; in the parse helpers below bind dynamically. Without this the compiler +;; treats them as lexical (this file is lexical-binding), the bindings never +;; reach `json-read-file', and it returns json.el's default alist instead of +;; the hash tables the parsers maphash over. The runtime `(require 'json)' +;; inside each helper still keeps json off the load-time path. +(eval-when-compile (require 'json)) + (defvar cj/coverage-backends nil "Registry of coverage backends in priority order. Each entry is a plist with at least :name, :detect, :run, and :report-path. -- cgit v1.2.3