Derive SYMBOL-LOOKUP intern name via symbol-name - #15
Open
genworks wants to merge 1 commit into
Open
Conversation
…r lowercase readtable-case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This way, lookups will work under lowercase readtable-case.
coloring-types.lispresolves the per-language lookup functions atruntime via
(intern "SYMBOL-LOOKUP" :clhs-lookup)(likewise:r5rs-lookup,:elisp-lookup,:cocoa-lookup— four sites). Theruntime intern is clearly deliberate, since the lookup packages are
optional and
find-package-guarded — but the hardcoded uppercasestring isn't case-portable. String literals don't follow
readtable-case, while definition names do: on an implementationwhose symbols read lowercase (e.g. modern-mode Allegro CL, where
readtable-caseis:preserveover lowercase standard symbols),(defun symbol-lookup ...)interns"symbol-lookup", and theuppercase string-intern creates a distinct, unfbound symbol. The
result is an
undefined-functionerror whenever a Lisp code block iscolorized.
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
:upcaseimplementation this is provably a no-op.On stock SBCL:
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 :invertthe lowercasedefunnamesinvert to
"SYMBOL-LOOKUP"and match the hardcoded string. Thestring literal's immunity to
readtable-caseis exactly the bug.)