Fix #508 - nil fiber environment.

run-context did not handle a nil environment well, so that was fixed
and ev/call inherits the environment when creating the fiber.
This commit is contained in:
Calvin Rose 2020-11-26 19:04:45 -06:00
parent 451340e4c0
commit 6c43489fb2
2 changed files with 2 additions and 1 deletions

View File

@ -2120,7 +2120,7 @@
:parser parser
:read read
:expander expand} opts)
(default env (fiber/getenv (fiber/current)))
(default env (or (fiber/getenv (fiber/current)) @{}))
(default chunks (fn [buf p] (getline "" buf env)))
(default onstatus debug/stacktrace)
(default on-compile-error bad-compile)

View File

@ -1684,6 +1684,7 @@ static Janet cfun_ev_call(int32_t argc, Janet *argv) {
janet_arity(argc, 1, -1);
JanetFunction *fn = janet_getfunction(argv, 0);
JanetFiber *fiber = janet_fiber(fn, 64, argc - 1, argv + 1);
fiber->env = janet_current_fiber()->env;
if (NULL == fiber) janet_panicf("invalid arity to function %v", argv[0]);
janet_schedule(fiber, janet_wrap_nil());
return janet_wrap_fiber(fiber);