Make sure every thing returns a value under REPL mode.
@@ -27,12 +27,16 @@ func (p *Parser) parseStatement() ast.Statement {
default:
exp := p.parseExpressionStatement()
- // In REPL mode everything should return a value.
- if p.Mode != REPLMode &&
// If parseExpressionStatement got error exp.Expression would be nil
- (exp.Expression != nil) {
+ if exp.Expression != nil {
+ // In REPL mode everything should return a value.
+ if p.Mode == REPLMode {
+ exp.Expression.MarkAsExp()
+
+ } else {
exp.Expression.MarkAsStmt()
}
+ }
return exp
}
