Minimal reproduction:
use steel::{
SteelVal,
steel_vm::{engine::Engine, register_fn::RegisterFn},
};
async fn add_with_context(ctx: i32, value: i32) -> i32 {
ctx + value
}
fn main() {
let mut engine = Engine::new();
engine.register_value("*ctx*", SteelVal::IntV(10));
engine.register_fn_with_ctx(
"*ctx*",
"add-with-context",
add_with_context,
);
let result = engine.run("(add-with-context 1)");
println!("{result:?}");
}
Err(SteelErr { repr: Repr { kind: ArityMismatch, message: "add-with-context expected 2 argument, got 1", span: Some(1..17), stack_trace: Some(DehydratedStackTrace { stack_trace: [] }) } })
Seems supply_context_arg in impl RegisterValue for Engine only handle SteelVal::BoxedFunction
|
impl RegisterValue for Engine { |
|
fn register_value_inner(&mut self, name: &str, value: SteelVal) -> &mut Self { |
|
let idx = self.virtual_machine.compiler.write().register(name); |
|
self.virtual_machine.insert_binding(idx, value); |
|
self |
|
} |
|
|
|
fn supply_context_arg(&mut self, ctx: &'static str, name: &'static str) -> &mut Self { |
|
if let Ok(existing) = self.extract_value(name) { |
|
if let SteelVal::BoxedFunction(f) = &existing { |
|
let func = generate_function(self, &SteelString::from(ctx), &existing, f); |
|
self.register_value(name, func); |
|
} |
|
} |
|
|
|
self |
|
} |
|
} |
Minimal reproduction:
Seems
supply_context_arginimpl RegisterValue for Engineonly handleSteelVal::BoxedFunctionsteel/crates/steel-core/src/steel_vm/engine.rs
Lines 437 to 454 in 3a418c9