sasagawa888 / eisl

ISLisp interpreter/compiler
Other
267 stars 22 forks source link

Problems continuing conditions when using unwind-protect with with-handler #277

Closed gtnoble closed 1 year ago

gtnoble commented 1 year ago

When using unwind-protect and with-handler and continuing overflow and underflow conditions, forms are not evaluated in proper order. The tests below should pass.

(import "test")

(defun mult-underflow ()
  (* 1E-200 1E-200))

(defun mult-overflow ()
  (* *positive-infinity*))

(defun add-overflow ()
  (+ *positive-infinity*))

(defun test-underflow-overflow (underflowing)
  ($assert-ordered-operations '(first second third fourth) 
                              (unwind-protect 
                                (with-handler (lambda (condition)
                                                (record-operation 'second)
                                                (continue-condition condition))
                                              (record-operation 'first)
                                              (funcall underflowing)
                                              (record-operation 'third))
                                (record-operation 'fourth))))

(test-underflow-overflow #'mult-underflow)
(test-underflow-overflow #'mult-overflow)
(test-underflow-overflow #'add-overflow)
sasagawa888 commented 1 year ago

Fixed.

gtnoble commented 1 year ago

Thanks again! This helps me a lot with my project.