diff --git a/src/eval/mod.rs b/src/eval/mod.rs index db50ee82e..d39c3c2c3 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -354,7 +354,7 @@ fn eval_code( break; } - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; + let tail = eval_code(ctx, scp, exprs)?.display(); Value::Content(tail.styled_with_map(styles)) } Expr::Show(show) => { @@ -364,12 +364,12 @@ fn eval_code( break; } - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; + let tail = eval_code(ctx, scp, exprs)?.display(); Value::Content(tail.styled_with_entry(entry)) } Expr::Wrap(wrap) => { - let tail = to_content(eval_code(ctx, scp, exprs)?).at(span)?; - scp.top.def_mut(wrap.binding().take(), Value::Content(tail)); + let tail = eval_code(ctx, scp, exprs)?; + scp.top.def_mut(wrap.binding().take(), tail); wrap.body().eval(ctx, scp)? } @@ -386,14 +386,6 @@ fn eval_code( Ok(output) } -/// Extract content from a value. -fn to_content(value: Value) -> StrResult { - let ty = value.type_name(); - value - .cast() - .map_err(|_| format!("expected remaining block to yield content, found {ty}")) -} - impl Eval for ContentBlock { type Output = Content; diff --git a/src/library/layout/page.rs b/src/library/layout/page.rs index 324ac285d..ed9a03a40 100644 --- a/src/library/layout/page.rs +++ b/src/library/layout/page.rs @@ -159,7 +159,7 @@ impl Marginal { Self::Content(content) => Some(content.clone()), Self::Func(func, span) => { let args = Args::from_values(*span, [Value::Int(page as i64)]); - func.call(ctx, args)?.cast().at(*span)? + Some(func.call(ctx, args)?.display()) } }) } diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs index 6bcc9f3ea..7686a3f4a 100644 --- a/src/library/structure/list.rs +++ b/src/library/structure/list.rs @@ -217,7 +217,7 @@ impl Label { Self::Content(content) => content.clone(), Self::Func(func, span) => { let args = Args::from_values(*span, [Value::Int(number as i64)]); - func.call(ctx, args)?.cast().at(*span)? + func.call(ctx, args)?.display() } }) } diff --git a/src/model/recipe.rs b/src/model/recipe.rs index 905e035ec..3404a3849 100644 --- a/src/model/recipe.rs +++ b/src/model/recipe.rs @@ -1,7 +1,7 @@ use std::fmt::{self, Debug, Formatter}; use super::{Content, Interruption, NodeId, Show, ShowNode, StyleChain, StyleEntry}; -use crate::diag::{At, TypResult}; +use crate::diag::TypResult; use crate::eval::{Args, Func, Regex, Value}; use crate::library::structure::{EnumNode, ListNode}; use crate::syntax::Span; @@ -87,7 +87,7 @@ impl Recipe { Args::from_values(self.span, [arg()]) }; - self.func.call(ctx, args)?.cast().at(self.span) + Ok(self.func.call(ctx, args)?.display()) } /// What kind of structure the property interrupts. diff --git a/tests/ref/structure/enum.png b/tests/ref/structure/enum.png index a9111f577..0fcae99d2 100644 Binary files a/tests/ref/structure/enum.png and b/tests/ref/structure/enum.png differ diff --git a/tests/ref/style/show-node.png b/tests/ref/style/show-node.png index 3cb3539c5..63be751ae 100644 Binary files a/tests/ref/style/show-node.png and b/tests/ref/style/show-node.png differ diff --git a/tests/ref/style/wrap.png b/tests/ref/style/wrap.png index 82d1c34da..7fb8dfc58 100644 Binary files a/tests/ref/style/wrap.png and b/tests/ref/style/wrap.png differ diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ index b1045ee2e..7bd6fa88b 100644 --- a/tests/typ/structure/enum.typ +++ b/tests/typ/structure/enum.typ @@ -45,6 +45,11 @@ [Red], [Green], [Blue], ) +--- +#set enum(label: n => n > 1) +. A +. B + --- // Lone dot is not a list. . @@ -56,8 +61,3 @@ --- // Error: 18-24 invalid pattern #set enum(label: "(())") - ---- -// Error: 18-28 expected content, found boolean -#set enum(label: n => false) -. A diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ index 678ff1513..33895addd 100644 --- a/tests/typ/style/show-node.typ +++ b/tests/typ/style/show-node.typ @@ -76,7 +76,6 @@ Another text. } --- -// Error: 18-22 expected content, found integer #show heading as 1234 = Heading diff --git a/tests/typ/style/wrap.typ b/tests/typ/style/wrap.typ index 57f21f996..e37c4bc9f 100644 --- a/tests/typ/style/wrap.typ +++ b/tests/typ/style/wrap.typ @@ -25,8 +25,8 @@ A [_B #wrap c in [*#c*]; C_] D Forest --- +// Ok, whatever. { - // Error: 3-24 expected remaining block to yield content, found integer wrap body in 2 * body 2 }