Skip to content

Commit ea06f65

Browse files
committed
Fix callee execution order
1 parent 549a9be commit ea06f65

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

rust/kcl-lib/src/execution/fn_call.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ impl Node<CallExpressionKw> {
197197
let fn_name = &self.callee;
198198
let callsite: SourceRange = self.into();
199199

200+
// Clone the function so that we can use a mutable reference to
201+
// exec_state.
202+
let func = fn_name.get_result(exec_state, ctx).await?.clone();
203+
204+
let Some(fn_src) = func.as_function() else {
205+
return Err(KclError::new_semantic(KclErrorDetails::new(
206+
"cannot call this because it isn't a function".to_string(),
207+
vec![callsite],
208+
)));
209+
};
210+
200211
// Evaluate the unlabeled first param, if any exists.
201212
let unlabeled = if let Some(ref arg_expr) = self.unlabeled {
202213
let source_range = SourceRange::from(arg_expr.clone());
@@ -247,17 +258,6 @@ impl Node<CallExpressionKw> {
247258
exec_state.pipe_value().map(|v| Arg::new(v.clone(), callsite)),
248259
);
249260

250-
// Clone the function so that we can use a mutable reference to
251-
// exec_state.
252-
let func = fn_name.get_result(exec_state, ctx).await?.clone();
253-
254-
let Some(fn_src) = func.as_function() else {
255-
return Err(KclError::new_semantic(KclErrorDetails::new(
256-
"cannot call this because it isn't a function".to_string(),
257-
vec![callsite],
258-
)));
259-
};
260-
261261
let return_value = fn_src
262262
.call_kw(Some(fn_name.to_string()), exec_state, ctx, args, callsite)
263263
.await

0 commit comments

Comments
 (0)