fix promise bug
fix the second one in https://github.com/picrin-scheme/picrin/issues/339
This commit is contained in:
parent
842a0290f3
commit
d9f4380ae8
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue