Bugfix: double map (#4169)
Previously, map was wrapping KCL values in a JSON object unnecessarily. The new `double_map` test would emit this error: ``` Syntax(KclErrorDetails { source_ranges: [SourceRange([31, 32])], message: "Invalid number: {\"type\":\"UserVal\",\"value\":1.0,\"__meta\":[{\"sourceRange\":[31,36]}]}" }) ``` In other words, the second `map` statement is being passed an array of JSON STRINGS, not an array of numbers. The strings contain JSON stringified representations of user values which are numbers. Bug is now fixed.
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
fn increment = (i) => { return i + 1 }
|
||||
|
||||
xs = [0..2]
|
||||
ys = xs
|
||||
|> map(%, increment)
|
||||
|> map(%, increment)
|
@ -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) {
|
||||
@ -102,3 +110,4 @@ gen_test!(if_else);
|
||||
// );
|
||||
gen_test_fail!(comparisons_multiple, "syntax: Invalid number: true");
|
||||
gen_test!(add_lots);
|
||||
gen_test!(double_map);
|
||||
|
Reference in New Issue
Block a user