public object VisitReturnStmt(Stmt.Return stmt) { object value = null; if (stmt.value != null) { value = Evaluate(stmt.value); } throw new Return(value); }
public object VisitReturnStmt(Stmt.Return stmt) { if (currentFunction == FunctionType.None) { Basil.Error(stmt.keyword, "Cannot return from top level code."); } if (stmt.value != null) { if (currentFunction == FunctionType.Initializer) { Basil.Error(stmt.keyword, "Cannot return a value from an initializer."); } Resolve(stmt.value); } return(null); }