fix promise bug

fix the second one in https://github.com/picrin-scheme/picrin/issues/339
This commit is contained in:
stibear 2016-06-02 22:28:49 +09:00 committed by Yuichi Nishiwaki
parent 842a0290f3
commit d9f4380ae8
2 changed files with 17 additions and 4 deletions

View File

@ -43,10 +43,13 @@
(if (promise-done? promise)
(promise-value promise)
(let ((new-promise ((promise-value promise))))
(set-promise-done! promise (promise-done? new-promise))
(set-promise-value! promise (promise-value new-promise))
(set-box! new-promise (unbox promise))
(force promise))))
(if (promise-done? promise)
(promise-value promise)
(begin
(set-promise-done! promise (promise-done? new-promise))
(set-promise-value! promise (promise-value new-promise))
(set-box! new-promise (unbox promise))
(force promise))))))
(define (make-promise obj)
(if (and (box? obj) (promise? obj))

View File

@ -372,6 +372,16 @@
(force op)
(test 'ok (force np)))
(let ()
(define flag #f)
(define p (delay (if flag
'ok
(begin
(set! flag #t)
(force p)
'ng))))
(test 'ok (force p)))
(define radix
(make-parameter