1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-16 18:29:56 +00:00

Fix regression in while loops inside each macros.

There was a specialization for `(while (not= nil _) ...)` that
was incorrect when the while loop regresses to a thunk.
This commit is contained in:
Calvin Rose 2020-01-19 16:25:10 -06:00
parent 68a5667a1a
commit f4ad627b54
2 changed files with 2 additions and 2 deletions

View File

@ -2115,7 +2115,7 @@
(if-let [check (in module/cache fullpath)]
check
(do
(def loader (module/loaders mod-kind))
(def loader (if (keyword? mod-kind) (module/loaders mod-kind) mod-kind))
(unless loader (error (string "module type " mod-kind " unknown")))
(def env (loader fullpath args))
(put module/cache fullpath env)

View File

@ -630,7 +630,7 @@ static JanetSlot janetc_while(JanetFopts opts, int32_t argn, const Janet *argv)
janetc_scope(&tempscope, c, JANET_SCOPE_FUNCTION, "while-iife");
/* Recompile in the function scope */
cond = janetc_value(subopts, argv[0]);
cond = janetc_value(subopts, condform);
if (!(cond.flags & JANET_SLOT_CONSTANT)) {
/* If not an infinite loop, return nil when condition false */
janetc_emit_si(c, ifjmp, cond, 2, 0);