Skip to content

Commit 79b9b5e

Browse files
Emit a warning for let without a value
1 parent 5c762ab commit 79b9b5e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

askama_derive/src/generator/node.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use std::str::FromStr;
77

88
use parser::expr::BinOp;
99
use parser::node::{
10-
Call, Comment, Cond, CondTest, Create, FilterBlock, If, Include, Let, Lit, Loop, Match, Whitespace, Ws,
10+
Call, Comment, Cond, CondTest, Create, FilterBlock, If, Include, Let, Lit, Loop, Match,
11+
Whitespace, Ws,
1112
};
1213
use parser::{Expr, Node, Span, Target, WithSpan};
1314
use proc_macro2::TokenStream;
@@ -861,6 +862,14 @@ impl<'a> Generator<'a, '_> {
861862
let span = ctx.span_for_node(l.span());
862863

863864
let Some(val) = &l.val else {
865+
let file_info = ctx
866+
.file_info_of(l.span())
867+
.map(|info| format!(" {}:", info.to_string()))
868+
.unwrap_or(String::new());
869+
eprintln!(
870+
"⚠️{file_info} `let` tag will stop supporting declaring variables without value. \
871+
Use `create` instead for this case",
872+
);
864873
self.write_buf_writable(ctx, buf)?;
865874
buf.write_token(Token![let], span);
866875
if l.is_mutable {

0 commit comments

Comments
 (0)