Merge a517a08d2fc50706654bb649db496b21b47f421b into 9b09146a6b5e936966ed7ee73bce9dd2df3810ae

This commit is contained in:
T0mstone 2025-05-07 22:24:37 +00:00 committed by GitHub
commit 5e901812f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -285,6 +285,19 @@ impl Eval for ast::CodeBlock<'_> {
fn eval(self, vm: &mut Vm) -> SourceResult<Self::Output> {
vm.scopes.enter();
if let Some((span, kind)) =
self.body().exprs().next_back().and_then(|x| match x {
ast::Expr::ShowRule(_) => Some((x.span(), "show")),
ast::Expr::SetRule(_) => Some((x.span(), "set")),
_ => None,
})
{
vm.engine.sink.warn(typst_library::diag::warning!(
span,
"{kind} rule has no effect";
hint: "See https://typst.app/docs/tutorial/making-a-template/#set-and-show-rules"
));
}
let output = self.body().eval(vm)?;
vm.scopes.exit();
Ok(output)

View File

@ -0,0 +1,12 @@
--- warn-show-set-last-in-block ---
#{
// Warning: 1-14 show rule has no effect
// Hint: 1-14 See https://typst.app/docs/tutorial/making-a-template/#set-and-show-rules
show "a": "b"
}
#{
// Warning: 1-15 set rule has no effect
// Hint: 1-15 See https://typst.app/docs/tutorial/making-a-template/#set-and-show-rules
set text(blue)
}