Skip to content

Commit

Permalink
env: Fix macro-function with local functions
Browse files Browse the repository at this point in the history
See clasp-developers/clasp#1556. macro-function did not respect
local function shadowing, so with code like
(macrolet ((g ...)) (flet ((g ...)) ...)) it would return the
macro, inappropriately.
  • Loading branch information
Bike committed Jan 31, 2024
1 parent e6fb601 commit e41eae5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Environment/eval.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
(defgeneric macro-function (symbol environment))

;;; The default method specialized to ENTRY is called for entries that
;;; are not of type MACRO. This method just makes a recursive call,
;;; passing the next environment as an argument.
;;; are not of type MACRO or FUNCTION. This method just makes a
;;; recursive call, passing the next environment as an argument.
(defmethod macro-function (symbol (environment entry))
(macro-function symbol (next environment)))

Expand All @@ -156,6 +156,14 @@
(expander environment)
(macro-function symbol (next environment))))

;;; This method is invoked when the environment is of type FUNCTION so
;;; it might potentially contain a shadowing function. If it does, we
;;; return NIL immediately; otherwise we continue searching.
(defmethod macro-function (symbol (environment function))
(if (eq symbol (name environment))
nil
(macro-function symbol (next environment))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Generic function COMPILER-MACRO-FUNCTION
Expand Down

0 comments on commit e41eae5

Please sign in to comment.