diff --git a/src/wasm-lib/kcl/src/std/array.rs b/src/wasm-lib/kcl/src/std/array.rs index 925a7efb89..5ecc658587 100644 --- a/src/wasm-lib/kcl/src/std/array.rs +++ b/src/wasm-lib/kcl/src/std/array.rs @@ -28,6 +28,18 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result Ok(user_val.value), + _ => Err(()), + }) + .collect::, _>>(); + if let Ok(unwrapped) = unwrapped { + let uv = UserVal::new(vec![args.source_range.into()], unwrapped); + return Ok(KclValue::UserVal(uv)); + } let uv = UserVal::new(vec![args.source_range.into()], new_array); Ok(KclValue::UserVal(uv)) } diff --git a/src/wasm-lib/tests/executor/inputs/no_visuals/double_map.kcl b/src/wasm-lib/tests/executor/inputs/no_visuals/double_map.kcl index 5fd7552fd7..93f9d77113 100644 --- a/src/wasm-lib/tests/executor/inputs/no_visuals/double_map.kcl +++ b/src/wasm-lib/tests/executor/inputs/no_visuals/double_map.kcl @@ -1,5 +1,6 @@ fn increment = (i) => { return i + 1 } xs = [0..2] +ys = xs |> map(%, increment) |> map(%, increment) diff --git a/src/wasm-lib/tests/executor/no_visuals.rs b/src/wasm-lib/tests/executor/no_visuals.rs index 37f86e486c..c5e2cb0ab1 100644 --- a/src/wasm-lib/tests/executor/no_visuals.rs +++ b/src/wasm-lib/tests/executor/no_visuals.rs @@ -28,7 +28,15 @@ macro_rules! gen_test_fail { async fn run(code: &str) { let (ctx, program, id_generator) = setup(code).await; - ctx.run(&program, None, id_generator).await.unwrap(); + let res = ctx.run(&program, None, id_generator).await; + match res { + Ok(state) => { + println!("{:#?}", state.memory); + } + Err(e) => { + panic!("{e}"); + } + } } async fn setup(program: &str) -> (ExecutorContext, Program, IdGenerator) {