fix import of top-level thunks

This commit is contained in:
Folkert 2020-12-12 17:56:43 +01:00
parent 3d827f40f4
commit 05a6b30644
4 changed files with 11 additions and 4 deletions

View file

@ -4758,6 +4758,8 @@ fn reuse_function_symbol<'a>(
.from_var(env.arena, arg_var, env.subs)
.expect("creating layout does not fail");
add_needed_external(procs, env, arg_var, original);
procs.insert_passed_by_name(
env,
arg_var,
@ -4765,6 +4767,11 @@ fn reuse_function_symbol<'a>(
layout.clone(),
layout_cache,
);
// an imported symbol is always a function pointer:
// either it's a function, or a top-level 0-argument thunk
let expr = Expr::FunctionPointer(original, layout.clone());
return Stmt::Let(original, expr, layout, env.arena.alloc(result));
}
_ => {
// danger: a foreign symbol may not be specialized!