From 2cc4c6fafb348988af871cc6835a78999da24e72 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sun, 30 Jun 2019 14:56:27 +0100 Subject: [PATCH] next is already sitting at correct token, no need to advance. Fixes #38 --- src/lib/syntax/parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/syntax/parser.rs b/src/lib/syntax/parser.rs index f5437c1d26..8c537d5045 100644 --- a/src/lib/syntax/parser.rs +++ b/src/lib/syntax/parser.rs @@ -151,14 +151,14 @@ impl Parser { let cond = self.parse()?; self.expect_punc(Punctuator::CloseParen, "if block")?; let expr = self.parse()?; - let next = self.get_token(self.pos + 1); + let next = self.get_token(self.pos); Ok(mk!( self, ExprDef::IfExpr( Box::new(cond), Box::new(expr), if next.is_ok() && next.unwrap().data == TokenData::Keyword(Keyword::Else) { - self.pos += 2; + self.pos += 1; Some(Box::new(self.parse()?)) } else { None