Skip to content

Commit

Permalink
fix: add test for @let without block, fix spans for error
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio authored and lambda-fairy committed Jan 6, 2025
1 parent 137b392 commit 90bb109
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions maud/tests/warnings/let-without-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use maud::html;

fn main() {
html! {
p.@let x = 1; {
(x)
}
};
}
5 changes: 5 additions & 0 deletions maud/tests/warnings/let-without-block.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: `@let` bindings are only allowed inside blocks
--> tests/warnings/let-without-block.rs:5:11
|
5 | p.@let x = 1; {
| ^^^^^^^^^^^
5 changes: 3 additions & 2 deletions maud_macros/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ impl DiagnosticParse for Markup {
let markup = Self::diagnostic_parse_in_block(input, diagnostics)?;

if let Self::ControlFlow(ControlFlow {
kind: ControlFlowKind::Let(expr),
kind: ControlFlowKind::Let(_),
..
}) = &markup
{
diagnostics.push(
expr.span()
markup
.span()
.error("`@let` bindings are only allowed inside blocks"),
)
}
Expand Down

0 comments on commit 90bb109

Please sign in to comment.