feat: Add pipe parameter validation and fix VM call frame

Adds a check within the `PipeHook` to ensure the number of input streams
provided to a `pipe` operation matches the number of parameters expected
by the associated lambda function. This prevents runtime errors and
provides a clearer compile-time diagnostic.

Additionally, this commit corrects the order in which a `CallFrame` is
pushed onto the VM's frame stack. By pushing the frame earlier, it
ensures that slow-path `unpack` operations have access to a valid frame,
preventing "No call frame" errors.
This commit is contained in:
2026-03-30 09:43:58 +02:00
parent e82d48d1cb
commit 9b13546609
4 changed files with 85 additions and 10 deletions
+7 -5
View File
@@ -239,6 +239,13 @@ impl VM {
self.stack.clear();
self.frames.clear();
// Push the call frame early so that `unpack` (slow path) can use
// `set_value` / `get_value`, which require a valid call frame.
self.frames.push(CallFrame {
stack_base: 0,
closure: Some(closure_rc.clone()),
});
let closure = closure_rc.as_ref();
if let Some(count) = closure.positional_count
&& args.len() == count as usize
@@ -254,11 +261,6 @@ impl VM {
self.stack.resize(closure.stack_size as usize, Value::Void);
}
self.frames.push(CallFrame {
stack_base: 0,
closure: Some(closure_rc.clone()),
});
let result = self.eval_internal(observer, &closure.exec_node);
self.frames.pop();
self.resolve_tail_calls(observer, result)