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
+20
View File
@@ -93,6 +93,26 @@ fn test_pipe_chain_preserves_concrete_types() {
assert!(env.run_script(source).is_ok(), "Chained pipe failed at runtime");
}
/// Pipe with 2 input streams but lambda expecting 1 parameter must be a compile error.
/// Regression: previously crashed at runtime with "No call frame" instead of a
/// clean compile-time diagnostic.
#[test]
fn test_pipe_param_count_mismatch_is_compile_error() {
let env = Environment::new();
let source = "(do
(def src (create-random-ohlc 42 5))
(pipe [src src] (fn [bar] (.close bar)))
)";
let res = env.run_script(source);
assert!(res.is_err(), "Pipe with 2 inputs but 1-param lambda must be a compile error");
let err = res.unwrap_err();
assert!(
err.contains("pipe") && err.contains("parameter"),
"Error should mention parameter mismatch, got: {err}"
);
}
/// Verifies that pipe with Optional return (filter pattern) still produces Stream(Float).
#[test]
fn test_pipeline_optional_type() {