ruricolist / serapeum

Utilities beyond Alexandria
MIT License
425 stars 42 forks source link

ECL seems to complain about MATCHED-TYPES being bound with let #58

Closed pouar closed 4 years ago

pouar commented 4 years ago
[package serapeum/dispatch-case].
;;; Error:
;;;   in file dispatch-case.lisp, position 959
;;;   at (FSET 'WITH-MATCHED-TYPE ...)
;;;   * The constant MATCHED-TYPES is being bound.
Condition of type: COMPILE-FILE-ERROR
COMPILE-FILE-ERROR while compiling #<cl-source-file "serapeum" "level2" "dispatch-case">

The following patch seems to pacify it

diff --git a/dispatch-case.lisp b/dispatch-case.lisp
index d739f01..93560ae 100644
--- a/dispatch-case.lisp
+++ b/dispatch-case.lisp
@@ -22,16 +22,16 @@
 (define-symbol-macro matched-types ())

 (defmacro with-matched-type (type &body body &environment env)
-  (let ((matched-types (macroexpand-1 'matched-types env)))
-    `(symbol-macrolet ((matched-types ,(cons type matched-types)))
+  (let ((%matched-types (macroexpand-1 'matched-types env)))
+    `(symbol-macrolet ((matched-types ,(cons type %matched-types)))
        ,@body)))

 (defmacro dispatch-case-error (&key type datum &environment env)
-  (let ((matched-types (macroexpand-1 'matched-types env)))
+  (let ((%matched-types (macroexpand-1 'matched-types env)))
     `(error 'dispatch-case-error
             :expected-type ,type
             :datum ,datum
-            :matched-types ',(butlast matched-types))))
+            :matched-types ',(butlast %matched-types))))

 (defun clause-leading-type (clause)
   (caar clause))
pouar commented 4 years ago

no idea if this is intended behavior in ECL or a bug in ECL though

pouar commented 4 years ago

Also, for some reason, it only complains about this with the C compiler, but not the byte compiler

ruricolist commented 4 years ago

If you want to make a pull request I'd be happy to merge it.