2014-10-07 19:32:34 |
Anton |
description |
SBCL version 1.2.4, using optima pattern matching library: https://github.com/m2ym/optima
Compiling file with this code will fail without declaring dispatch-error notinline.
(in-package #:test-dump-error)
(defun dispatch-error (code)
(error ;; <-- ATTENTION HERE
;; dispatch on error code
(case code
(100 'parse-error)
(otherwise 'error))))
(defmacro match-with-error (response matcher)
`(match ,response
((alist (:ERROR . code))
(dispatch-error code))
,matcher))
(defun api-call-response (resp)
(match-with-error
resp
((alist (:RESPONSE . data)) data)))
Compiler error:
; compiling file "/home/freeman/err.lisp" (written 07 OCT 2014 09:19:44 PM):
; compiling (DEFPACKAGE #:TEST-DUMP-ERROR ...)
; compiling (IN-PACKAGE #:TEST-DUMP-ERROR)
; compiling (DEFUN DISPATCH-ERROR ...)
; compiling (DEFMACRO MATCH-WITH-ERROR ...)
; compiling (DEFUN PARSE-RESPONSE ...)
; file: /home/freeman/err.lisp
; in: DEFUN PARSE-RESPONSE
; (TEST-DUMP-ERROR::MATCH-WITH-ERROR TEST-DUMP-ERROR::RESP
; ((OPTIMA.EXTRA:ALIST
; (:RESPONSE . TEST-DUMP-ERROR::DATA))
; TEST-DUMP-ERROR::DATA))
; --> OPTIMA:MATCH OPTIMA::%OR BLOCK SB-C::%COMPILE-TIME-TYPE-ERROR
; ==>
; '((BLOCK #:BLOCK43
; (TAGBODY
; (RETURN-FROM #:BLOCK43
; (SYMBOL-MACROLET #
; #))
; #:FAIL44
; (RETURN-FROM #:BLOCK43 (OPTIMA::%OR # NIL))))
; (TEST-DUMP-ERROR::DISPATCH-ERROR TEST-DUMP-ERROR::CODE))
;
; caught ERROR:
; don't know how to dump CODE (default MAKE-LOAD-FORM method called).
; --> OPTIMA:MATCH OPTIMA::%OR BLOCK
; ==>
; (SB-C::%COMPILE-TIME-TYPE-ERROR 'SB-C::DUMMY 'NIL '*
; '((BLOCK #:BLOCK43
; (TAGBODY
; (RETURN-FROM #:BLOCK43 #)
; #:FAIL44
; (RETURN-FROM #:BLOCK43 #)))
; (TEST-DUMP-ERROR::DISPATCH-ERROR
; TEST-DUMP-ERROR::CODE)))
;
; note: The fourth argument never returns a value.
Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
{1002BF7023}>:
The value NIL is not of type (AND ATOM (NOT NULL)).
Changing ERROR to SIGNAL in DISPATCH-ERROR also makes code compiles without any problem. |
SBCL version 1.2.4, using optima pattern matching library: https://github.com/m2ym/optima
Compiling file with this code will fail without declaring signal-error notinline.
(defun signal-error ()
(error 'error))
(defun will-fail ()
(optima:match 1
((not 2)
(signal-error))))
Error report:
; compiling (DEFUN SIGNAL-ERROR ...)
; compiling (DEFUN WILL-FAIL ...)
; file: /home/freeman/err.lisp
; in: DEFUN WILL-FAIL
; (OPTIMA:MATCH 1
; ((NOT 2) (COMMON-LISP::SIGNAL-ERROR)))
; --> LET OPTIMA::%OR BLOCK SB-C::%COMPILE-TIME-TYPE-ERROR
; ==>
; '((BLOCK #:BLOCK2
; (TAGBODY
; (RETURN-FROM #:BLOCK2
; (SYMBOL-MACROLET #
; #))
; #:FAIL3
; (RETURN-FROM #:BLOCK2 NIL)))
; (COMMON-LISP::SIGNAL-ERROR))
;
; caught ERROR:
; don't know how to dump 2 (default MAKE-LOAD-FORM method called).
; --> LET OPTIMA::%OR BLOCK
; ==>
; (SB-C::%COMPILE-TIME-TYPE-ERROR 'SB-C::DUMMY 'NIL '*
; '((BLOCK #:BLOCK2
; (TAGBODY
; (RETURN-FROM #:BLOCK2 #)
; #:FAIL3
; (RETURN-FROM #:BLOCK2 NIL)))
; (COMMON-LISP::SIGNAL-ERROR)))
;
; note: The fourth argument never returns a value.
Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
{1002BF7023}>:
The value NIL is not of type (AND ATOM (NOT NULL)).
After declaring singnal-error as notinline or changing ERROR to SIGNAL it'll compile ok. |
|