1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-29 14:47:42 +00:00

Support looking up missing symbols during compilation

This commit is contained in:
Michael Camilleri
2022-01-21 13:07:11 +09:00
parent 2f3b4c8bfb
commit 1eb34989d4
3 changed files with 23 additions and 2 deletions

View File

@@ -2746,6 +2746,8 @@
(and as (string as "/"))
prefix
(string (last (string/split "/" path)) "/")))
(unless (zero? (length prefix))
(put-in env [:modules prefix] newenv))
(merge-module env newenv prefix ep))
(defmacro import

View File

@@ -607,8 +607,14 @@ JanetBinding janet_resolve_ext(JanetTable *env, const uint8_t *sym) {
};
/* Check environment for entry */
if (!janet_checktype(entry, JANET_TABLE))
return binding;
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 args[2] = { janet_wrap_symbol(sym), janet_wrap_table(env) };
entry = janet_call(janet_unwrap_function(fn_entry), 2, args);
}
if (!janet_checktype(entry, JANET_TABLE)) return binding;
}
entry_table = janet_unwrap_table(entry);
/* deprecation check */