diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-10-27 15:37:00 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-10-27 15:38:08 +0200 |
| commit | 24a0bd8cfb170a002b5266e4dfd3da007b4fc145 (patch) | |
| tree | fa6cad002049f661291ecd0186d64a7a90f15468 /crates/typst-macros/src/func.rs | |
| parent | cbfd9884a94b55486f9b07296f23a01b34d080bd (diff) | |
Fix error priority for function arguments
Errors about superfluous arguments are now thrown before errors of the function execution itself.
Fixes #1367
Diffstat (limited to 'crates/typst-macros/src/func.rs')
| -rw-r--r-- | crates/typst-macros/src/func.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/typst-macros/src/func.rs b/crates/typst-macros/src/func.rs index 5b8501d0..b67fb909 100644 --- a/crates/typst-macros/src/func.rs +++ b/crates/typst-macros/src/func.rs @@ -307,6 +307,9 @@ fn create_wrapper_closure(func: &Func) -> TokenStream { } }; + // Throws errors about unexpected arguments. + let finish = (!func.special.args).then(|| quote! { args.take().finish()?; }); + // This is the actual function call. let call = { let self_ = func @@ -332,6 +335,7 @@ fn create_wrapper_closure(func: &Func) -> TokenStream { |vm, args| { let __typst_func = #parent #ident; #handlers + #finish let output = #call; ::typst::eval::IntoResult::into_result(output, args.span) } |
