Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differing behavior in ASDF-loaded vs interactively compiled function accessing constant #1580

Open
paulapatience opened this issue May 7, 2024 · 0 comments
Labels

Comments

@paulapatience
Copy link
Contributor

After loading the clasp-table-bug system provided below, calling (gethash-table "a") returns NIL instead of 0, but after compiling the function interactively, it behaves correctly.

cat >clasp-table-bug.asd <<EOF
(defsystem "clasp-table-bug"
  :depends-on ("alexandria" "shasht")
  :components ((:file "clasp-table-bug")))
EOF

cat >clasp-table-bug.lisp <<EOF
(uiop:define-package #:clasp-table-bug
  (:use #:common-lisp))
(in-package #:clasp-table-bug)

;; With DEFPARAMETER, it works.
(alexandria:define-constant +table+
  ;; With this, it works.
  #+(or)
  (alexandria:plist-hash-table (list "a" 0) :test 'equal)
  (shasht:read-json "{\"a\":0}")
  :test 'equalp)

(defun gethash-table (name)
  (gethash name +table+))

;; This returns NIL at first, until you recompile the function
#+(or)
(gethash-table "a")

;; This returns the right thing
#+(or)
(gethash "a" +table+)
EOF

The system depends on Alexandria and shasht.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant