mirror of
https://github.com/janet-lang/janet
synced 2024-11-05 16:26:17 +00:00
Avoid panicking when calling :missing-symbol lookup function
This commit is contained in:
parent
ed5c1dfc3c
commit
d396180939
@ -608,10 +608,17 @@ JanetBinding janet_resolve_ext(JanetTable *env, const uint8_t *sym) {
|
|||||||
|
|
||||||
/* Check environment for entry */
|
/* Check environment for entry */
|
||||||
if (!janet_checktype(entry, JANET_TABLE)) {
|
if (!janet_checktype(entry, JANET_TABLE)) {
|
||||||
Janet fn_entry = janet_table_get(env, janet_ckeywordv("missing-symbol"));
|
Janet lookup_entry = janet_table_get(env, janet_ckeywordv("missing-symbol"));
|
||||||
if (janet_checktype(fn_entry, JANET_FUNCTION)) {
|
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) };
|
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;
|
if (!janet_checktype(entry, JANET_TABLE)) return binding;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user