mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Merge a517a08d2fc50706654bb649db496b21b47f421b into 9b09146a6b5e936966ed7ee73bce9dd2df3810ae
This commit is contained in:
commit
5e901812f3
@ -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)
|
||||
|
12
tests/suite/styling/in-block.typ
Normal file
12
tests/suite/styling/in-block.typ
Normal 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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user