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
parent dd75267f8e
commit 3d2dd7cefc
2 changed files with 15 additions and 4 deletions

View File

@ -24,9 +24,12 @@
(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))
(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))
(force promise))))))
(define (make-promise obj)
(if (promise? obj)

View File

@ -363,7 +363,15 @@
(force x)
(promise? x)))
(let ()
(define flag #f)
(define p (delay (if flag
'ok
(begin
(set! flag #t)
(force p)
'ng))))
(test 'ok (force p)))
(define radix