Unify execution state into a single struct (#3877)
* Add ExecState that combines ProgramMemory and DynamicState * Remove unneeded clones * Add exec_state parameter to all KCL stdlib functions * Move pipe value into ExecState * Add test for pipe substitution not leaking into function calls * KCL: Better message on assertEqual function Also add a new no-visual test for performance testing. * Fix new array module to use ExecState --------- Co-authored-by: Adam Chalmers <adam.chalmers@zoo.dev>
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
// Make sure pipe value doesn't leak into the function call.
|
||||
fn f = (ignored) => {
|
||||
return %
|
||||
}
|
||||
|
||||
const answer = %
|
||||
|> f(%)
|
@ -85,5 +85,9 @@ gen_test_fail!(
|
||||
object_prop_not_found,
|
||||
"undefined value: Property 'age' not found in object"
|
||||
);
|
||||
gen_test_fail!(
|
||||
pipe_substitution_inside_function_called_from_pipeline,
|
||||
"semantic: cannot use % outside a pipe expression"
|
||||
);
|
||||
gen_test!(sketch_group_in_object);
|
||||
gen_test!(add_lots);
|
||||
|
@ -35,12 +35,12 @@ async fn setup(code: &str, name: &str) -> Result<(ExecutorContext, Program, uuid
|
||||
let parser = kcl_lib::parser::Parser::new(tokens);
|
||||
let program = parser.ast()?;
|
||||
let ctx = kcl_lib::executor::ExecutorContext::new(&client, Default::default()).await?;
|
||||
let memory = ctx.run(&program, None).await?;
|
||||
let exec_state = ctx.run(&program, None).await?;
|
||||
|
||||
// We need to get the sketch ID.
|
||||
// Get the sketch group ID from memory.
|
||||
let KclValue::UserVal(user_val) = memory.get(name, SourceRange::default()).unwrap() else {
|
||||
anyhow::bail!("part001 not found in memory: {:?}", memory);
|
||||
let KclValue::UserVal(user_val) = exec_state.memory.get(name, SourceRange::default()).unwrap() else {
|
||||
anyhow::bail!("part001 not found in memory: {:?}", exec_state.memory);
|
||||
};
|
||||
let Some((sketch_group, _meta)) = user_val.get::<SketchGroup>() else {
|
||||
anyhow::bail!("part001 was not a SketchGroup");
|
||||
|
Reference in New Issue
Block a user