mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
Fix #428
Add binding check for generate verb in loops. The check is present in other loop verbs.
This commit is contained in:
parent
5c364e0f7c
commit
08a3687eb5
@ -471,10 +471,12 @@
|
||||
:in (each-template binding object [rest])
|
||||
:iterate (iterate-template binding object rest)
|
||||
:generate (with-syms [f s]
|
||||
(def ds (if (idempotent? binding) binding (gensym)))
|
||||
~(let [,f ,object]
|
||||
(while true
|
||||
(def ,binding (,resume ,f))
|
||||
(def ,ds (,resume ,f))
|
||||
(if (= :dead (,fiber/status ,f)) (break))
|
||||
,;(if (= ds binding) [] [~(def ,binding ,ds)])
|
||||
,rest)))
|
||||
(error (string "unexpected loop verb " verb)))))
|
||||
|
||||
|
@ -319,4 +319,10 @@ neldb\0\0\0\xD8\x05printG\x01\0\xDE\xDE\xDE'\x03\0marshal_tes/\x02
|
||||
(check-jdn "a string")
|
||||
(check-jdn @"a buffer")
|
||||
|
||||
# Issue 428
|
||||
(var result nil)
|
||||
(defn f [] (yield {:a :ok}))
|
||||
(assert-no-error "issue 428 1" (loop [{:a x} :generate (fiber/new f)] (set result x)))
|
||||
(assert (= result :ok) "issue 428 2")
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user