diff --git a/crates/parser/src/grammar.pest b/crates/parser/src/grammar.pest index 4eb57ce..12376dd 100644 --- a/crates/parser/src/grammar.pest +++ b/crates/parser/src/grammar.pest @@ -75,7 +75,7 @@ program = { visibility = { "pub" ~ ("(" ~ static_path ~ ")")? } mutable = { "mut" } -var = { "var" } +let_kw = { "let" } // ====================================================== // GENERICS @@ -190,7 +190,7 @@ attributes = { // DECLARATION HELPERS // ====================================================== var_decl = { - (var | type_expr) ~ pattern + (let_kw | type_expr) ~ pattern } field = { diff --git a/crates/parser/src/parser/common/decl.rs b/crates/parser/src/parser/common/decl.rs index 288745c..b0af0e0 100644 --- a/crates/parser/src/parser/common/decl.rs +++ b/crates/parser/src/parser/common/decl.rs @@ -54,7 +54,7 @@ impl<'a> TryFrom> for VarDecl { let type_ = inner .next() .and_then(|pair| { - if pair.as_str().trim() == "var" { + if pair.as_rule() == Rule::let_kw { None } else { Some(TypeExpr::try_from(pair))