Merge pull request #341 from stibear/lazy2

fix promise bugs on corner cases (second one)
This commit is contained in:
Yuichi Nishiwaki 2016-06-02 22:34:24 +09:00
commit 15f048d0da
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