Skip to content

Commit

Permalink
fix: more error handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhairs committed Aug 3, 2023
1 parent a07e2d1 commit 5738acd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions glox/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (p *Parser) printStatement() (ast.Statement, error) {
if err != nil {
return nil, err
}
if _, e := p.consume(token.SEMICOLON, "expect ';' after value."); e != nil {
err = e
if _, err = p.consume(token.SEMICOLON, "expect ';' after value."); err != nil {
return nil, err
}
return ast.NewPrintStmt(exp), err

Expand All @@ -136,8 +136,8 @@ func (p *Parser) expressionStatement() (ast.Statement, error) {
if err != nil {
return nil, err
}
if _, e := p.consume(token.SEMICOLON, "expect ';' after value."); e != nil {
err = e
if _, err = p.consume(token.SEMICOLON, "expect ';' after value."); err != nil {
return nil, err
}
return ast.NewExprStmt(exp), err
}
Expand Down

0 comments on commit 5738acd

Please sign in to comment.