From 704dc29e95f2709ae781cd494e0e898ffc756e48 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sun, 03 May 2026 02:15:08 +0000 Subject: [PATCH] refactor: drop default args parser --- --- a/crates/jrsonnet-evaluator/src/function/mod.rs +++ b/crates/jrsonnet-evaluator/src/function/mod.rs @@ -19,7 +19,6 @@ pub mod builtin; mod native; -mod parse; pub(crate) mod prepared; pub use jrsonnet_ir::function::*; --- a/crates/jrsonnet-evaluator/src/function/parse.rs +++ /dev/null @@ -1,39 +0,0 @@ -use std::rc::Rc; - -use crate::{ - Context, ContextBuilder, Result, Thunk, - analyze::LFunction, - evaluate::{destructure::destruct, evaluate}, -}; - -/// Creates Context with all argument default values applied -/// and with unbound values causing error to be returned. -pub fn parse_default_function_call(body_ctx: Context, func: &Rc) -> Result { - let fctx = Context::new_future(); - let mut builder = ContextBuilder::extend(body_ctx, func.params.len()); - - for param in &func.params { - if let Some(default_expr) = ¶m.default { - let default_expr = default_expr.clone(); - let fctxc = fctx.clone(); - let thunk = Thunk!(move || { - let ctx = fctxc.unwrap(); - evaluate(ctx, &default_expr) - }); - destruct(¶m.destruct, thunk, fctx.clone(), &mut builder); - } else { - let name = param.name.clone().unwrap_or_else(|| "".into()); - let thunk = Thunk::errored( - crate::error::ErrorKind::FunctionParameterNotBoundInCall( - jrsonnet_ir::function::ParamName::Named(name), - jrsonnet_ir::function::FunctionSignature::empty(), - ) - .into(), - ); - destruct(¶m.destruct, thunk, fctx.clone(), &mut builder); - } - } - - let ctx = builder.build().into_future(fctx); - Ok(ctx) -} -- gitstuff