Avoid panicking when calling :missing-symbol lookup function
@@ -608,10 +608,17 @@ JanetBinding janet_resolve_ext(JanetTable *env, const uint8_t *sym) {
/* Check environment for entry */
if (!janet_checktype(entry, JANET_TABLE)) {
- Janet fn_entry = janet_table_get(env, janet_ckeywordv("missing-symbol"));
- if (janet_checktype(fn_entry, JANET_FUNCTION)) {
+ Janet lookup_entry = janet_table_get(env, janet_ckeywordv("missing-symbol"));
+ if (janet_checktype(lookup_entry, JANET_FUNCTION)) {
+ JanetFunction *lookup = janet_unwrap_function(lookup_entry);
Janet args[2] = { janet_wrap_symbol(sym), janet_wrap_table(env) };
- entry = janet_call(janet_unwrap_function(fn_entry), 2, args);
+ JanetFiber *fiberp = janet_fiber(lookup, 64, 2, args);
+ if (NULL == fiberp) return binding;
+ fiberp->env = env;
+ int lock = janet_gclock();
+ JanetSignal status = janet_continue(fiberp, janet_wrap_nil(), &entry);
+ janet_gcunlock(lock);
+ if (status != JANET_SIGNAL_OK) return binding;
}
if (!janet_checktype(entry, JANET_TABLE)) return binding;
}
