Skip to content

Derive SYMBOL-LOOKUP intern name via symbol-name - #15

Open
genworks wants to merge 1 commit into
kingcons:masterfrom
genworks:master
Open

Derive SYMBOL-LOOKUP intern name via symbol-name #15
genworks wants to merge 1 commit into
kingcons:masterfrom
genworks:master

Conversation

@genworks

@genworks genworks commented Aug 4, 2026

Copy link
Copy Markdown

This way, lookups will work under lowercase readtable-case.

coloring-types.lisp resolves the per-language lookup functions at
runtime via (intern "SYMBOL-LOOKUP" :clhs-lookup) (likewise
:r5rs-lookup, :elisp-lookup, :cocoa-lookup — four sites). The
runtime intern is clearly deliberate, since the lookup packages are
optional and find-package-guarded — but the hardcoded uppercase
string isn't case-portable. String literals don't follow
readtable-case, while definition names do: on an implementation
whose symbols read lowercase (e.g. modern-mode Allegro CL, where
readtable-case is :preserve over lowercase standard symbols),
(defun symbol-lookup ...) interns "symbol-lookup", and the
uppercase string-intern creates a distinct, unfbound symbol. The
result is an undefined-function error whenever a Lisp code block is
colorized.

This patch derives the name the same way the definition's name was
derived — (intern (symbol-name '#:symbol-lookup) :clhs-lookup)
so it matches under any readtable-case.

On a conforming :upcase implementation this is provably a no-op.
On stock SBCL:

(string= (symbol-name '#:symbol-lookup) "SYMBOL-LOOKUP")  ; => T
(eq (intern (symbol-name '#:symbol-lookup) :clhs-lookup)
    (intern "SYMBOL-LOOKUP" :clhs-lookup))                 ; => T

Under modern-mode Allegro CL, (symbol-name '#:symbol-lookup) yields
"symbol-lookup", matching the actual definitions — verified there:
the patched form resolves to the genuine fbound symbol-lookup,
where the hardcoded string previously landed on an unbound symbol.

(No pure-SBCL failing testcase is possible for this one via readtable
tricks: under readtable-case :invert the lowercase defun names
invert to "SYMBOL-LOOKUP" and match the hardcoded string. The
string literal's immunity to readtable-case is exactly the bug.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant