git.delta.rocks / jrsonnet / refs/commits / 704dc29e95f2

difftreelog

refactor drop default args parser

uslxmzwlYaroslav Bolyukin2026-05-05parent: #5858c93.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
1919
20pub mod builtin;20pub mod builtin;
21mod native;21mod native;
22mod parse;
23pub(crate) mod prepared;22pub(crate) mod prepared;
2423
25pub use jrsonnet_ir::function::*;24pub use jrsonnet_ir::function::*;
deletedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
--- 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<LFunction>) -> Result<Context> {
-	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) = &param.default {
-			let default_expr = default_expr.clone();
-			let fctxc = fctx.clone();
-			let thunk = Thunk!(move || {
-				let ctx = fctxc.unwrap();
-				evaluate(ctx, &default_expr)
-			});
-			destruct(&param.destruct, thunk, fctx.clone(), &mut builder);
-		} else {
-			let name = param.name.clone().unwrap_or_else(|| "<param>".into());
-			let thunk = Thunk::errored(
-				crate::error::ErrorKind::FunctionParameterNotBoundInCall(
-					jrsonnet_ir::function::ParamName::Named(name),
-					jrsonnet_ir::function::FunctionSignature::empty(),
-				)
-				.into(),
-			);
-			destruct(&param.destruct, thunk, fctx.clone(), &mut builder);
-		}
-	}
-
-	let ctx = builder.build().into_future(fctx);
-	Ok(ctx)
-}