aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/grammar/items/mod.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs
index 73fd5235a..00c52dc09 100644
--- a/src/parser/grammar/items/mod.rs
+++ b/src/parser/grammar/items/mod.rs
@@ -267,13 +267,24 @@ fn fn_item(p: &mut Parser) {
267 m.complete(p, BLOCK); 267 m.complete(p, BLOCK);
268 } 268 }
269 269
270 // test let_stmt;
271 // fn foo() {
272 // let a;
273 // let b: i32;
274 // let c = 92;
275 // let d: i32 = 92;
276 // }
270 fn let_stmt(p: &mut Parser) { 277 fn let_stmt(p: &mut Parser) {
271 assert!(p.at(LET_KW)); 278 assert!(p.at(LET_KW));
272 let m = p.start(); 279 let m = p.start();
273 p.bump(); 280 p.bump();
274 patterns::pattern(p); 281 patterns::pattern(p);
275 p.expect(EQ); 282 if p.eat(COLON) {
276 expressions::expr(p); 283 types::type_(p);
284 }
285 if p.eat(EQ) {
286 expressions::expr(p);
287 }
277 p.expect(SEMI); 288 p.expect(SEMI);
278 m.complete(p, LET_STMT); 289 m.complete(p, LET_STMT);
279 } 290 }