public Void visitReturnStmt(Stmt.Return stmt) { object value = null; if (stmt.value != null) { value = Evaluate(stmt.value); } throw new Return(value); }
public Void visitReturnStmt(Stmt.Return stmt) { if (currentFunction == FunctionType.NONE) { Program.Error(stmt.keyword, "Cannot return from top level code"); } if (stmt.value != null) { Resolve(stmt.value); } return(null); }