浏览代码

Remove experimental continuation support (#2776)

Removes `__continuation`, `__await`, and `__run`.

In part here, the discussion was that while the feature had been useful for validating the early explorer design, it's no longer needed for that role as the explorer is now quite robust. Continuations have been experimental and, at this point, don't have an owner pushing to a proposal.

The triggering factor is that, as we push to address fuzzer issues, I ran into a crash bug in this code; basically, `fn Main() -> i32 { __await; return 0; }`. When I mentioned this, the reaction seemed to trend towards removal of the feature.
Jon Ross-Perkins 3 年之前
父节点
当前提交
39155d34ae
共有 49 个文件被更改,包括 13 次插入2665 次删除
  1. 13 29
      common/fuzzing/carbon.proto
  2. 0 24
      common/fuzzing/proto_to_carbon.cpp
  3. 0 82
      explorer/README.md
  4. 0 4
      explorer/ast/ast_kinds.h
  5. 0 4
      explorer/ast/expression.cpp
  6. 0 14
      explorer/ast/expression.h
  7. 0 18
      explorer/ast/statement.cpp
  8. 0 99
      explorer/ast/statement.h
  9. 0 11
      explorer/ast/value.cpp
  10. 0 57
      explorer/ast/value.h
  11. 0 2
      explorer/ast/value_kinds.def
  12. 0 5
      explorer/ast/value_transform.h
  13. 0 23
      explorer/fuzzing/ast_to_proto.cpp
  14. 0 351
      explorer/fuzzing/fuzzer_corpus/37fcecce96eb5c913f090b2f1f588e3b82c9d1be
  15. 0 88
      explorer/fuzzing/fuzzer_corpus/5947862acd3e020041dcd43ca86f05438a6ab930
  16. 0 51
      explorer/fuzzing/fuzzer_corpus/63378befc2730b6eeca04e21fc914fce5442844b
  17. 0 135
      explorer/fuzzing/fuzzer_corpus/879519ec3f915d5bec166b7c1adbea9be016060b
  18. 0 97
      explorer/fuzzing/fuzzer_corpus/91362973dc5b0ed1e93d5f4e8e1e0b21ed98c3e9
  19. 0 153
      explorer/fuzzing/fuzzer_corpus/96a504c8350c3d69aef1eb3c63f43f73acc6a899
  20. 0 63
      explorer/fuzzing/fuzzer_corpus/96f494f4264c4c5ff5f351423d60ab98f6a6b12b
  21. 0 173
      explorer/fuzzing/fuzzer_corpus/bbabf13bb9fd0c2a5c1b23eaaf572dce295176a8
  22. 0 316
      explorer/fuzzing/fuzzer_corpus/e347085328903bbd4f362337d32f45315dc3bf18
  23. 0 88
      explorer/fuzzing/fuzzer_corpus/e38f21d3adb5fb5eb8138b5175401a9ccfe1163d
  24. 0 186
      explorer/fuzzing/fuzzer_corpus/eb9859dd8a2ab2a66b93655aeb5f01090a55978d
  25. 0 2
      explorer/interpreter/BUILD
  26. 0 45
      explorer/interpreter/action_stack.cpp
  27. 0 13
      explorer/interpreter/action_stack.h
  28. 0 50
      explorer/interpreter/interpreter.cpp
  29. 0 6
      explorer/interpreter/resolve_control_flow.cpp
  30. 0 17
      explorer/interpreter/resolve_names.cpp
  31. 0 4
      explorer/interpreter/resolve_unformed.cpp
  32. 0 48
      explorer/interpreter/stack_fragment.cpp
  33. 0 51
      explorer/interpreter/stack_fragment.h
  34. 0 36
      explorer/interpreter/type_checker.cpp
  35. 0 1
      explorer/interpreter/type_structure.cpp
  36. 0 8
      explorer/syntax/lexer.lpp
  37. 0 15
      explorer/syntax/parser.ypp
  38. 0 26
      explorer/testdata/experimental_continuation/await_maintains_scope.carbon
  39. 0 31
      explorer/testdata/experimental_continuation/convert_run.carbon
  40. 0 20
      explorer/testdata/experimental_continuation/creation_is_noop.carbon
  41. 0 18
      explorer/testdata/experimental_continuation/fail_auto_return_await.carbon
  42. 0 17
      explorer/testdata/experimental_continuation/fail_continuation_syntax.carbon
  43. 0 29
      explorer/testdata/experimental_continuation/fail_lifetime.carbon
  44. 0 20
      explorer/testdata/experimental_continuation/fail_recursive_continuation.carbon
  45. 0 18
      explorer/testdata/experimental_continuation/fail_return_in_continuation.carbon
  46. 0 40
      explorer/testdata/experimental_continuation/recursive.carbon
  47. 0 21
      explorer/testdata/experimental_continuation/run.carbon
  48. 0 25
      explorer/testdata/experimental_continuation/run_with_await.carbon
  49. 0 31
      explorer/testdata/experimental_continuation/shallow_copy.carbon

+ 13 - 29
common/fuzzing/carbon.proto

@@ -114,7 +114,6 @@ message BoolLiteral {
 }
 
 message IntTypeLiteral {}
-message ContinuationTypeLiteral {}
 
 message IntLiteral {
   optional int64 value = 1;
@@ -177,16 +176,15 @@ message Expression {
     BoolTypeLiteral bool_type_literal = 12;
     BoolLiteral bool_literal = 13;
     IntTypeLiteral int_type_literal = 14;
-    ContinuationTypeLiteral continuation_type_literal = 15;
-    IntLiteral int_literal = 16;
-    StringLiteral string_literal = 17;
-    StringTypeLiteral string_type_literal = 18;
-    TypeTypeLiteral type_type_literal = 19;
-    UnimplementedExpression unimplemented_expression = 20;
-    ArrayTypeLiteral array_type_literal = 21;
-    CompoundMemberAccessExpression compound_member_access = 22;
-    WhereExpression where = 23;
-    DesignatorExpression designator = 24;
+    IntLiteral int_literal = 15;
+    StringLiteral string_literal = 16;
+    StringTypeLiteral string_type_literal = 17;
+    TypeTypeLiteral type_type_literal = 18;
+    UnimplementedExpression unimplemented_expression = 19;
+    ArrayTypeLiteral array_type_literal = 20;
+    CompoundMemberAccessExpression compound_member_access = 21;
+    WhereExpression where = 22;
+    DesignatorExpression designator = 23;
   }
 }
 
@@ -319,17 +317,6 @@ message MatchStatement {
   repeated MatchClause clauses = 2;
 }
 
-message ContinuationStatement {
-  optional string name = 1;
-  optional BlockStatement body = 2;
-}
-
-message RunStatement {
-  optional Expression argument = 1;
-}
-
-message AwaitStatement {}
-
 message BreakStatement {}
 message ContinueStatement {}
 
@@ -344,13 +331,10 @@ message Statement {
     BlockStatement block = 7;
     WhileStatement while_statement = 8;
     MatchStatement match = 9;
-    ContinuationStatement continuation = 10;
-    RunStatement run = 11;
-    AwaitStatement await_statement = 12;
-    BreakStatement break_statement = 13;
-    ContinueStatement continue_statement = 14;
-    ForStatement for_statement = 15;
-    IncrementDecrementStatement inc_dec = 16;
+    BreakStatement break_statement = 10;
+    ContinueStatement continue_statement = 11;
+    ForStatement for_statement = 12;
+    IncrementDecrementStatement inc_dec = 13;
   }
 }
 

+ 0 - 24
common/fuzzing/proto_to_carbon.cpp

@@ -366,10 +366,6 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression,
       out << "String";
       break;
 
-    case Fuzzing::Expression::kContinuationTypeLiteral:
-      out << "__Continuation";
-      break;
-
     case Fuzzing::Expression::kTypeTypeLiteral:
       out << "type";
       break;
@@ -676,26 +672,6 @@ static auto StatementToCarbon(const Fuzzing::Statement& statement,
       break;
     }
 
-    case Fuzzing::Statement::kContinuation: {
-      const auto& continuation = statement.continuation();
-      out << "__continuation ";
-      IdentifierToCarbon(continuation.name(), out);
-      BlockStatementToCarbon(continuation.body(), out);
-      break;
-    }
-
-    case Fuzzing::Statement::kRun: {
-      const auto& run = statement.run();
-      out << "__run ";
-      ExpressionToCarbon(run.argument(), out);
-      out << ";";
-      break;
-    }
-
-    case Fuzzing::Statement::kAwaitStatement:
-      out << "__await;";
-      break;
-
     case Fuzzing::Statement::kBreakStatement:
       out << "break;";
       break;

+ 0 - 82
explorer/README.md

@@ -191,85 +191,3 @@ Each step of execution is printed in the following format:
 
 Each step of execution can push new actions on the stack, pop actions, increment
 the position number of an action, and add result values to an action.
-
-## Experimental feature: Delimited Continuations
-
-Delimited continuations provide a kind of resumable exception with first-class
-continuations. The point of experimenting with this feature is not to say that
-we want delimited continuations in Carbon, but this represents a place-holder
-for other powerful control-flow features that might eventually be in Carbon,
-such as coroutines, threads, exceptions, etc. As we refactor the executable
-semantics, having this feature in place will keep us honest and prevent us from
-accidentally simplifying the interpreter to the point where it can't handle
-features like this one.
-
-Instead of delimited continuations, we could have instead done regular
-continuations with callcc. However, there seems to be a consensus amongst the
-experts that delimited continuations are better than regular ones.
-
-So what are delimited continuations? Recall that a continuation is a
-representation of what happens next in a computation. In the abstract machine,
-the procedure call stack represents the current continuation. A delimited
-continuation is also about what happens next, but it doesn't go all the way to
-the end of the execution. Instead it represents what happens up until control
-reaches the nearest enclosing `__continuation` statement.
-
-The statement
-
-    __continuation <identifier> <statement>
-
-creates a continuation object from the given statement and binds the
-continuation object to the given identifier. The given statement is not yet
-executed.
-
-The statement
-
-    __run <expression>;
-
-starts or resumes execution of the continuation object that results from the
-given expression.
-
-The statement
-
-    __await;
-
-pauses the current continuation, saving the control state in the continuation
-object. Control is then returned to the statement after the `__run` that
-initiated the current continuation.
-
-These three language features are demonstrated in the following example, where
-we create a continuation and bind it to `k`. We then run the continuation twice.
-The first time increments `x` to `1` and the second time increments `x` to `2`,
-so the expected result of this program is `2`.
-
-```carbon
-fn Main() -> i32 {
-  var x: i32 = 0;
-  __continuation k {
-    x = x + 1;
-    __await;
-    x = x + 1;
-  }
-  __run k;
-  __run k;
-  return x;
-}
-```
-
-Note that the control state of the continuation object bound to `k` mutates as
-the program executes. Upon creation, the control state is at the beginning of
-the continuation. After the first `__run`, the control state is just after the
-`__await`. After the second `__run`, the control state is at the end of the
-continuation.
-
-Continuation variables are currently copyable, but that operation is "shallow":
-the two values are aliases for the same underlying continuation object.
-
-The delimited continuation feature described here is based on the
-`shift`/`reset` style of delimited continuations created by Danvy and Filinsky
-(Abstracting control, ACM Conference on Lisp and Functional Programming, 1990).
-We adapted the feature to operate in a more imperative manner. The
-`__continuation` feature is equivalent to a `reset` followed immediately by a
-`shift` to pause and capture the continuation object. The `__run` feature is
-equivalent to calling the continuation. The `__await` feature is equivalent to a
-`shift` except that it updates the continuation in place.

+ 0 - 4
explorer/ast/ast_kinds.h

@@ -105,9 +105,6 @@
   FINAL(Break)                                          \
   FINAL(Continue)                                       \
   FINAL(Match)                                          \
-  FINAL(Continuation)                                   \
-  FINAL(Run)                                            \
-  FINAL(Await)                                          \
   FINAL(For)
 
 #define CARBON_Return_KINDS(ABSTRACT, FINAL) \
@@ -124,7 +121,6 @@
       ABSTRACT(MemberAccessExpression)                 \
   FINAL(IndexExpression)                               \
   FINAL(IntTypeLiteral)                                \
-  FINAL(ContinuationTypeLiteral)                       \
   FINAL(IntLiteral)                                    \
   FINAL(OperatorExpression)                            \
   FINAL(StringLiteral)                                 \

+ 0 - 4
explorer/ast/expression.cpp

@@ -300,7 +300,6 @@ void Expression::Print(llvm::raw_ostream& out) const {
     case ExpressionKind::StringLiteral:
     case ExpressionKind::StringTypeLiteral:
     case ExpressionKind::TypeTypeLiteral:
-    case ExpressionKind::ContinuationTypeLiteral:
     case ExpressionKind::ValueLiteral:
       PrintID(out);
       break;
@@ -338,9 +337,6 @@ void Expression::PrintID(llvm::raw_ostream& out) const {
     case ExpressionKind::TypeTypeLiteral:
       out << "type";
       break;
-    case ExpressionKind::ContinuationTypeLiteral:
-      out << "Continuation";
-      break;
     case ExpressionKind::FunctionTypeLiteral:
     case ExpressionKind::StructLiteral:
     case ExpressionKind::ArrayTypeLiteral:

+ 0 - 14
explorer/ast/expression.h

@@ -817,20 +817,6 @@ class IntTypeLiteral : public Expression {
   }
 };
 
-class ContinuationTypeLiteral : public Expression {
- public:
-  explicit ContinuationTypeLiteral(SourceLocation source_loc)
-      : Expression(AstNodeKind::ContinuationTypeLiteral, source_loc) {}
-
-  explicit ContinuationTypeLiteral(CloneContext& context,
-                                   const ContinuationTypeLiteral& other)
-      : Expression(context, other) {}
-
-  static auto classof(const AstNode* node) -> bool {
-    return InheritsFromContinuationTypeLiteral(node->kind());
-  }
-};
-
 class TypeTypeLiteral : public Expression {
  public:
   explicit TypeTypeLiteral(SourceLocation source_loc)

+ 0 - 18
explorer/ast/statement.cpp

@@ -123,24 +123,6 @@ void Statement::PrintDepth(int depth, llvm::raw_ostream& out) const {
       }
       break;
     }
-    case StatementKind::Continuation: {
-      const auto& cont = cast<Continuation>(*this);
-      out << "continuation " << cont.name() << " ";
-      if (depth < 0 || depth > 1) {
-        out << "\n";
-      }
-      cont.body().PrintDepth(depth - 1, out);
-      if (depth < 0 || depth > 1) {
-        out << "\n";
-      }
-      break;
-    }
-    case StatementKind::Run:
-      out << "run " << cast<Run>(*this).argument() << ";";
-      break;
-    case StatementKind::Await:
-      out << "await;";
-      break;
   }
 }
 

+ 0 - 99
explorer/ast/statement.h

@@ -581,105 +581,6 @@ class Match : public Statement {
   std::vector<Clause> clauses_;
 };
 
-// A continuation statement.
-//
-//     __continuation <continuation_variable> {
-//       <body>
-//     }
-class Continuation : public Statement {
- public:
-  using ImplementsCarbonValueNode = void;
-
-  Continuation(SourceLocation source_loc, std::string name,
-               Nonnull<Block*> body)
-      : Statement(AstNodeKind::Continuation, source_loc),
-        name_(std::move(name)),
-        body_(body) {}
-
-  explicit Continuation(CloneContext& context, const Continuation& other)
-      : Statement(context, other),
-        name_(other.name_),
-        body_(context.Clone(other.body_)),
-        static_type_(context.Clone(other.static_type_)) {}
-
-  static auto classof(const AstNode* node) -> bool {
-    return InheritsFromContinuation(node->kind());
-  }
-
-  auto name() const -> const std::string& { return name_; }
-  auto body() const -> const Block& { return *body_; }
-  auto body() -> Block& { return *body_; }
-
-  // The static type of the continuation. Cannot be called before typechecking.
-  //
-  // This will always be ContinuationType, but we must set it dynamically in
-  // the typechecker because this code can't depend on ContinuationType.
-  auto static_type() const -> const Value& { return **static_type_; }
-
-  // Sets the static type of the continuation. Can only be called once,
-  // during typechecking.
-  void set_static_type(Nonnull<const Value*> type) {
-    CARBON_CHECK(!static_type_.has_value());
-    static_type_ = type;
-  }
-
-  auto expression_category() const -> ExpressionCategory {
-    return ExpressionCategory::Reference;
-  }
-  auto constant_value() const -> std::optional<Nonnull<const Value*>> {
-    return std::nullopt;
-  }
-  auto symbolic_identity() const -> std::optional<Nonnull<const Value*>> {
-    return std::nullopt;
-  }
-
- private:
-  std::string name_;
-  Nonnull<Block*> body_;
-  std::optional<Nonnull<const Value*>> static_type_;
-};
-
-// A run statement.
-//
-//     __run <argument>;
-class Run : public Statement {
- public:
-  Run(SourceLocation source_loc, Nonnull<Expression*> argument)
-      : Statement(AstNodeKind::Run, source_loc), argument_(argument) {}
-
-  explicit Run(CloneContext& context, const Run& other)
-      : Statement(context, other), argument_(context.Clone(other.argument_)) {}
-
-  static auto classof(const AstNode* node) -> bool {
-    return InheritsFromRun(node->kind());
-  }
-
-  auto argument() const -> const Expression& { return *argument_; }
-  auto argument() -> Expression& { return *argument_; }
-
-  // Can only be called by type-checking, if a conversion was required.
-  void set_argument(Nonnull<Expression*> argument) { argument_ = argument; }
-
- private:
-  Nonnull<Expression*> argument_;
-};
-
-// An await statement.
-//
-//    __await;
-class Await : public Statement {
- public:
-  explicit Await(SourceLocation source_loc)
-      : Statement(AstNodeKind::Await, source_loc) {}
-
-  explicit Await(CloneContext& context, const Await& other)
-      : Statement(context, other) {}
-
-  static auto classof(const AstNode* node) -> bool {
-    return InheritsFromAwait(node->kind());
-  }
-};
-
 }  // namespace Carbon
 
 #endif  // CARBON_EXPLORER_AST_STATEMENT_H_

+ 0 - 11
explorer/ast/value.cpp

@@ -494,9 +494,6 @@ void Value::Print(llvm::raw_ostream& out) const {
     case Value::Kind::AutoType:
       out << "auto";
       break;
-    case Value::Kind::ContinuationType:
-      out << "Continuation";
-      break;
     case Value::Kind::PointerType:
       out << cast<PointerType>(*this).pointee_type() << "*";
       break;
@@ -672,10 +669,6 @@ void Value::Print(llvm::raw_ostream& out) const {
       out << "." << *GetName(assoc.constant()) << ")";
       break;
     }
-    case Value::Kind::ContinuationValue: {
-      out << cast<ContinuationValue>(*this).representation();
-      break;
-    }
     case Value::Kind::StringType:
       out << "String";
       break;
@@ -870,7 +863,6 @@ auto TypeEqual(Nonnull<const Value*> t1, Nonnull<const Value*> t2,
     }
     case Value::Kind::IntType:
     case Value::Kind::BoolType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::TypeType:
     case Value::Kind::StringType:
       return true;
@@ -898,7 +890,6 @@ auto TypeEqual(Nonnull<const Value*> t1, Nonnull<const Value*> t2,
     case Value::Kind::LocationValue:
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::UninitializedValue:
     case Value::Kind::ParameterizedEntityName:
     case Value::Kind::MemberName:
@@ -1034,7 +1025,6 @@ auto ValueStructurallyEqual(
     case Value::Kind::ConstraintWitness:
     case Value::Kind::ConstraintImplWitness:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::VariableType:
     case Value::Kind::StringType:
     case Value::Kind::TypeOfMixinPseudoType:
@@ -1047,7 +1037,6 @@ auto ValueStructurallyEqual(
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::PointerValue:
     case Value::Kind::LocationValue:
     case Value::Kind::UninitializedValue:

+ 0 - 57
explorer/ast/value.h

@@ -1290,21 +1290,6 @@ class ChoiceType : public Value {
   Nonnull<const Bindings*> bindings_;
 };
 
-// A continuation type.
-class ContinuationType : public Value {
- public:
-  ContinuationType() : Value(Kind::ContinuationType) {}
-
-  static auto classof(const Value* value) -> bool {
-    return value->kind() == Kind::ContinuationType;
-  }
-
-  template <typename F>
-  auto Decompose(F f) const {
-    return f();
-  }
-};
-
 // A variable type.
 class VariableType : public Value {
  public:
@@ -1449,48 +1434,6 @@ class AssociatedConstant : public Value {
   Nonnull<const Witness*> witness_;
 };
 
-// A first-class continuation representation of a fragment of the stack.
-// The representation of a continuation is opaque and determined by the
-// interpreter.
-class ContinuationValue : public Value {
- public:
-  // Base class for the representation of a continuation, which is not defined
-  // here for layering reasons. The interpreter provides the derived class
-  // `StackFragment` that defines the concrete representation, which is
-  // expected to be the only derived class outside of tests.
-  class Representation {
-   public:
-    virtual ~Representation() {}
-
-    Representation(Representation&&) = delete;
-    auto operator=(Representation&&) -> Representation& = delete;
-
-    virtual void Print(llvm::raw_ostream& out) const = 0;
-    LLVM_DUMP_METHOD void Dump() const { Print(llvm::errs()); }
-
-   protected:
-    Representation() = default;
-  };
-
-  explicit ContinuationValue(Nonnull<Representation*> representation)
-      : Value(Kind::ContinuationValue), representation_(representation) {}
-
-  static auto classof(const Value* value) -> bool {
-    return value->kind() == Kind::ContinuationValue;
-  }
-
-  template <typename F>
-  auto Decompose(F f) const {
-    return f(representation_);
-  }
-
-  // The representation of the continuation.
-  auto representation() const -> Representation& { return *representation_; }
-
- private:
-  Nonnull<Representation*> representation_;
-};
-
 // The String type.
 class StringType : public Value {
  public:

+ 0 - 2
explorer/ast/value_kinds.def

@@ -40,7 +40,6 @@ CARBON_VALUE_KIND(InterfaceType)
 CARBON_VALUE_KIND(NamedConstraintType)
 CARBON_VALUE_KIND(ConstraintType)
 CARBON_VALUE_KIND(ChoiceType)
-CARBON_VALUE_KIND(ContinuationType)
 CARBON_VALUE_KIND(VariableType)
 CARBON_VALUE_KIND(AssociatedConstant)
 CARBON_VALUE_KIND(ParameterizedEntityName)
@@ -48,7 +47,6 @@ CARBON_VALUE_KIND(MemberName)
 CARBON_VALUE_KIND(BindingPlaceholderValue)
 CARBON_VALUE_KIND(AddrValue)
 CARBON_VALUE_KIND(AlternativeConstructorValue)
-CARBON_VALUE_KIND(ContinuationValue)
 CARBON_VALUE_KIND(StringType)
 CARBON_VALUE_KIND(StringValue)
 CARBON_VALUE_KIND(TypeOfMixinPseudoType)

+ 0 - 5
explorer/ast/value_transform.h

@@ -236,11 +236,6 @@ class ValueTransform : public TransformBase<Derived, ResultUnwrapper> {
     return node;
   }
 
-  auto operator()(Nonnull<ContinuationValue::Representation*> continuation)
-      -> Nonnull<ContinuationValue::Representation*> {
-    return continuation;
-  }
-
   auto operator()(Address addr) -> Address { return addr; }
 
   auto operator()(ValueNodeView value_node) -> ValueNodeView {

+ 0 - 23
explorer/fuzzing/ast_to_proto.cpp

@@ -340,10 +340,6 @@ static auto ExpressionToProto(const Expression& expression)
       expression_proto.mutable_string_type_literal();
       break;
 
-    case ExpressionKind::ContinuationTypeLiteral:
-      expression_proto.mutable_continuation_type_literal();
-      break;
-
     case ExpressionKind::TypeTypeLiteral:
       expression_proto.mutable_type_type_literal();
       break;
@@ -565,25 +561,6 @@ static auto StatementToProto(const Statement& statement) -> Fuzzing::Statement {
       break;
     }
 
-    case StatementKind::Continuation: {
-      const auto& continuation = cast<Continuation>(statement);
-      auto* continuation_proto = statement_proto.mutable_continuation();
-      continuation_proto->set_name(continuation.name());
-      *continuation_proto->mutable_body() =
-          BlockStatementToProto(continuation.body());
-      break;
-    }
-
-    case StatementKind::Run:
-      *statement_proto.mutable_run()->mutable_argument() =
-          ExpressionToProto(cast<Run>(statement).argument());
-      break;
-
-    case StatementKind::Await:
-      // Initializes with the default value; there's nothing to set.
-      statement_proto.mutable_await_statement();
-      break;
-
     case StatementKind::Break:
       // Initializes with the default value; there's nothing to set.
       statement_proto.mutable_break_statement();

+ 0 - 351
explorer/fuzzing/fuzzer_corpus/37fcecce96eb5c913f090b2f1f588e3b82c9d1be

@@ -1,351 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    variable {
-      binding {
-        name: "current"
-        type {
-          expression_pattern {
-            expression {
-              int_type_literal {
-              }
-            }
-          }
-        }
-      }
-      initializer {
-        int_literal {
-          value: 0
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "CountUpTo"
-      }
-      param_pattern {
-        fields {
-          binding_pattern {
-            name: "x"
-            type {
-              expression_pattern {
-                expression {
-                  int_type_literal {
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          if_statement {
-            condition {
-              operator {
-                op: Eq
-                arguments {
-                  identifier {
-                    name: "x"
-                  }
-                }
-                arguments {
-                  int_literal {
-                    value: 0
-                  }
-                }
-              }
-            }
-            then_block {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "current"
-                    }
-                  }
-                  rhs {
-                    int_literal {
-                      value: 0
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                await_statement {
-                }
-              }
-              statements {
-                return_expression_statement {
-                  expression {
-                    int_literal {
-                      value: 0
-                    }
-                  }
-                }
-              }
-            }
-            else_block {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "current"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                      arguments {
-                        call {
-                          function {
-                            identifier {
-                              name: "CountUpTo"
-                            }
-                          }
-                          argument {
-                            tuple_literal {
-                              fields {
-                                operator {
-                                  op: Sub
-                                  arguments {
-                                    identifier {
-                                      name: "x"
-                                    }
-                                  }
-                                  arguments {
-                                    int_literal {
-                                      value: 1
-                                    }
-                                  }
-                                }
-                              }
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                await_statement {
-                }
-              }
-              statements {
-                return_expression_statement {
-                  expression {
-                    identifier {
-                      name: "current"
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                expression_statement {
-                  expression {
-                    call {
-                      function {
-                        identifier {
-                          name: "CountUpTo"
-                        }
-                      }
-                      argument {
-                        tuple_literal {
-                          fields {
-                            int_literal {
-                              value: 5
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "sum"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "count"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 5
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          while_statement {
-            condition {
-              operator {
-                op: NotEq
-                arguments {
-                  identifier {
-                    name: "count"
-                  }
-                }
-                arguments {
-                  int_literal {
-                    value: 0
-                  }
-                }
-              }
-            }
-            body {
-              statements {
-                run {
-                  argument {
-                    identifier {
-                      name: "k"
-                    }
-                  }
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "sum"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "sum"
-                        }
-                      }
-                      arguments {
-                        identifier {
-                          name: "current"
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "count"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Sub
-                      arguments {
-                        identifier {
-                          name: "count"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "sum"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 88
explorer/fuzzing/fuzzer_corpus/5947862acd3e020041dcd43ca86f05438a6ab930

@@ -1,88 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "x"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "x"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 51
explorer/fuzzing/fuzzer_corpus/63378befc2730b6eeca04e21fc914fce5442844b

@@ -1,51 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "f"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Auto
-      }
-      body {
-        statements {
-          await_statement {
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          return_expression_statement {
-            expression {
-              int_literal {
-                value: 0
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 135
explorer/fuzzing/fuzzer_corpus/879519ec3f915d5bec166b7c1adbea9be016060b

@@ -1,135 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "x"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                await_statement {
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 2
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "x"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 97
explorer/fuzzing/fuzzer_corpus/91362973dc5b0ed1e93d5f4e8e1e0b21ed98c3e9

@@ -1,97 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "x"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "x"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 153
explorer/fuzzing/fuzzer_corpus/96a504c8350c3d69aef1eb3c63f43f73acc6a899

@@ -1,153 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "capture"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          continuation_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "x"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 1
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                variable_definition {
-                  pattern {
-                    binding_pattern {
-                      name: "y"
-                      type {
-                        expression_pattern {
-                          expression {
-                            int_type_literal {
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                  init {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  is_returned: false
-                }
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "k"
-                type {
-                  expression_pattern {
-                    expression {
-                      continuation_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              call {
-                function {
-                  identifier {
-                    name: "capture"
-                  }
-                }
-                argument {
-                  tuple_literal {
-                  }
-                }
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              int_literal {
-                value: 0
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 63
explorer/fuzzing/fuzzer_corpus/96f494f4264c4c5ff5f351423d60ab98f6a6b12b

@@ -1,63 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "f"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Omitted
-      }
-      body {
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                run {
-                  argument {
-                    identifier {
-                      name: "k"
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          return_expression_statement {
-            expression {
-              int_literal {
-                value: 0
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 173
explorer/fuzzing/fuzzer_corpus/bbabf13bb9fd0c2a5c1b23eaaf572dce295176a8

@@ -1,173 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "y"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                variable_definition {
-                  pattern {
-                    binding_pattern {
-                      name: "x"
-                      type {
-                        expression_pattern {
-                          expression {
-                            int_type_literal {
-                            }
-                          }
-                        }
-                      }
-                    }
-                  }
-                  init {
-                    int_literal {
-                      value: 0
-                    }
-                  }
-                  is_returned: false
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                await_statement {
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 2
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "y"
-                    }
-                  }
-                  rhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k"
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "y"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 316
explorer/fuzzing/fuzzer_corpus/e347085328903bbd4f362337d32f45315dc3bf18

@@ -1,316 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    class_declaration {
-      name {
-        name: "Wrap"
-      }
-      members {
-        variable {
-          binding {
-            name: "v"
-            type {
-              expression_pattern {
-                expression {
-                  identifier {
-                    name: "T"
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      type_params {
-        fields {
-          generic_binding {
-            name: "T"
-            type {
-              type_type_literal {
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "MakeWrap"
-      }
-      deduced_parameters {
-        name: "T"
-        type {
-          type_type_literal {
-          }
-        }
-      }
-      param_pattern {
-        fields {
-          binding_pattern {
-            name: "x"
-            type {
-              expression_pattern {
-                expression {
-                  identifier {
-                    name: "T"
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      return_term {
-        kind: Expression
-        type {
-          call {
-            function {
-              identifier {
-                name: "Wrap"
-              }
-            }
-            argument {
-              tuple_literal {
-                fields {
-                  identifier {
-                    name: "T"
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-      body {
-        statements {
-          return_expression_statement {
-            expression {
-              struct_literal {
-                fields {
-                  name: "v"
-                  expression {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    impl {
-      kind: InternalImpl
-      impl_type {
-        call {
-          function {
-            identifier {
-              name: "Wrap"
-            }
-          }
-          argument {
-            tuple_literal {
-              fields {
-                identifier {
-                  name: "T"
-                }
-              }
-            }
-          }
-        }
-      }
-      interface {
-        call {
-          function {
-            identifier {
-              name: "ImplicitAs"
-            }
-          }
-          argument {
-            tuple_literal {
-              fields {
-                identifier {
-                  name: "T"
-                }
-              }
-            }
-          }
-        }
-      }
-      members {
-        function {
-          name {
-            name: "Convert"
-          }
-          self_pattern {
-            binding_pattern {
-              name: "self"
-              type {
-                expression_pattern {
-                  expression {
-                    identifier {
-                      name: "Self"
-                    }
-                  }
-                }
-              }
-            }
-          }
-          param_pattern {
-          }
-          return_term {
-            kind: Expression
-            type {
-              identifier {
-                name: "T"
-              }
-            }
-          }
-          body {
-            statements {
-              return_expression_statement {
-                expression {
-                  simple_member_access {
-                    field: "v"
-                    object {
-                      identifier {
-                        name: "self"
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "n"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 1
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "n"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "n"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-            }
-          }
-        }
-        statements {
-          assign {
-            lhs {
-              identifier {
-                name: "n"
-              }
-            }
-            rhs {
-              int_literal {
-                value: 2
-              }
-            }
-            op: Plain
-          }
-        }
-        statements {
-          run {
-            argument {
-              call {
-                function {
-                  identifier {
-                    name: "MakeWrap"
-                  }
-                }
-                argument {
-                  tuple_literal {
-                    fields {
-                      identifier {
-                        name: "k"
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "n"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 88
explorer/fuzzing/fuzzer_corpus/e38f21d3adb5fb5eb8138b5175401a9ccfe1163d

@@ -1,88 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "x"
-                type {
-                  expression_pattern {
-                    expression {
-                      int_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              int_literal {
-                value: 0
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          continuation {
-            name: "k"
-            body {
-              statements {
-                assign {
-                  lhs {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                  rhs {
-                    operator {
-                      op: Add
-                      arguments {
-                        identifier {
-                          name: "x"
-                        }
-                      }
-                      arguments {
-                        int_literal {
-                          value: 1
-                        }
-                      }
-                    }
-                  }
-                  op: Plain
-                }
-              }
-              statements {
-                return_expression_statement {
-                  expression {
-                    identifier {
-                      name: "x"
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 186
explorer/fuzzing/fuzzer_corpus/eb9859dd8a2ab2a66b93655aeb5f01090a55978d

@@ -1,186 +0,0 @@
-compilation_unit {
-  package_statement {
-    package_name: "ExplorerTest"
-  }
-  is_api: true
-  declarations {
-    variable {
-      binding {
-        name: "x"
-        type {
-          expression_pattern {
-            expression {
-              int_type_literal {
-              }
-            }
-          }
-        }
-      }
-      initializer {
-        int_literal {
-          value: 0
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Foo"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Omitted
-      }
-      body {
-        statements {
-          assign {
-            lhs {
-              identifier {
-                name: "x"
-              }
-            }
-            rhs {
-              operator {
-                op: Add
-                arguments {
-                  identifier {
-                    name: "x"
-                  }
-                }
-                arguments {
-                  int_literal {
-                    value: 1
-                  }
-                }
-              }
-            }
-            op: Plain
-          }
-        }
-        statements {
-          await_statement {
-          }
-        }
-        statements {
-          assign {
-            lhs {
-              identifier {
-                name: "x"
-              }
-            }
-            rhs {
-              operator {
-                op: Add
-                arguments {
-                  identifier {
-                    name: "x"
-                  }
-                }
-                arguments {
-                  int_literal {
-                    value: 2
-                  }
-                }
-              }
-            }
-            op: Plain
-          }
-        }
-      }
-    }
-  }
-  declarations {
-    function {
-      name {
-        name: "Main"
-      }
-      param_pattern {
-      }
-      return_term {
-        kind: Expression
-        type {
-          int_type_literal {
-          }
-        }
-      }
-      body {
-        statements {
-          continuation {
-            name: "k1"
-            body {
-              statements {
-                expression_statement {
-                  expression {
-                    call {
-                      function {
-                        identifier {
-                          name: "Foo"
-                        }
-                      }
-                      argument {
-                        tuple_literal {
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-        statements {
-          variable_definition {
-            pattern {
-              binding_pattern {
-                name: "k2"
-                type {
-                  expression_pattern {
-                    expression {
-                      continuation_type_literal {
-                      }
-                    }
-                  }
-                }
-              }
-            }
-            init {
-              identifier {
-                name: "k1"
-              }
-            }
-            is_returned: false
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k1"
-              }
-            }
-          }
-        }
-        statements {
-          run {
-            argument {
-              identifier {
-                name: "k2"
-              }
-            }
-          }
-        }
-        statements {
-          return_expression_statement {
-            expression {
-              identifier {
-                name: "x"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}

+ 0 - 2
explorer/interpreter/BUILD

@@ -31,11 +31,9 @@ cc_library(
     name = "action_stack",
     srcs = [
         "action_stack.cpp",
-        "stack_fragment.cpp",
     ],
     hdrs = [
         "action_stack.h",
-        "stack_fragment.h",
     ],
     deps = [
         ":action",

+ 0 - 45
explorer/interpreter/action_stack.cpp

@@ -95,23 +95,6 @@ void ActionStack::MergeScope(RuntimeScope scope) {
   CARBON_FATAL() << "No current scope";
 }
 
-void ActionStack::InitializeFragment(StackFragment& fragment,
-                                     Nonnull<const Statement*> body) {
-  std::vector<Nonnull<const RuntimeScope*>> scopes;
-  for (const std::unique_ptr<Action>& action : todo_) {
-    if (action->scope().has_value()) {
-      scopes.push_back(&*action->scope());
-    }
-  }
-  // We don't capture globals_ or constants_ because they're global.
-
-  std::vector<std::unique_ptr<Action>> reversed_todo;
-  reversed_todo.push_back(std::make_unique<StatementAction>(body));
-  reversed_todo.push_back(
-      std::make_unique<ScopeAction>(RuntimeScope::Capture(scopes)));
-  fragment.StoreReversed(std::move(reversed_todo));
-}
-
 namespace {
 // The way in which FinishAction should be called for a particular kind of
 // action.
@@ -268,34 +251,6 @@ auto ActionStack::UnwindPast(Nonnull<const Statement*> ast_node,
   return Success();
 }
 
-auto ActionStack::Resume(Nonnull<const ContinuationValue*> continuation)
-    -> ErrorOr<Success> {
-  Action& action = *todo_.Top();
-  action.set_pos(action.pos() + 1);
-  static_cast<StackFragment&>(continuation->representation()).RestoreTo(todo_);
-  return Success();
-}
-
-static auto IsRunAction(const Action& action) -> bool {
-  const auto* statement = llvm::dyn_cast<StatementAction>(&action);
-  return statement != nullptr && llvm::isa<Run>(statement->statement());
-}
-
-auto ActionStack::Suspend() -> ErrorOr<Success> {
-  // Pause the current continuation
-  todo_.Pop();
-  std::vector<std::unique_ptr<Action>> paused;
-  while (!IsRunAction(*todo_.Top())) {
-    paused.push_back(todo_.Pop());
-  }
-  const auto& continuation =
-      llvm::cast<const ContinuationValue>(*todo_.Top()->results()[0]);
-  // Update the continuation with the paused stack.
-  static_cast<StackFragment&>(continuation.representation())
-      .StoreReversed(std::move(paused));
-  return Success();
-}
-
 void ActionStack::PopScopes(
     std::stack<std::unique_ptr<Action>>& cleanup_stack) {
   while (!todo_.IsEmpty() && llvm::isa<ScopeAction>(*todo_.Top())) {

+ 0 - 13
explorer/interpreter/action_stack.h

@@ -13,7 +13,6 @@
 #include "explorer/ast/statement.h"
 #include "explorer/ast/value.h"
 #include "explorer/interpreter/action.h"
-#include "explorer/interpreter/stack_fragment.h"
 
 namespace Carbon {
 
@@ -56,11 +55,6 @@ class ActionStack {
   // Merges `scope` into the innermost scope currently on the stack.
   void MergeScope(RuntimeScope scope);
 
-  // Initializes `fragment` so that, when resumed, it begins execution of
-  // `body`.
-  void InitializeFragment(StackFragment& fragment,
-                          Nonnull<const Statement*> body);
-
   // The result produced by the `action` argument of the most recent
   // Start call. Cannot be called if IsEmpty() is false, or if `action`
   // was an action that doesn't produce results.
@@ -110,13 +104,6 @@ class ActionStack {
   auto UnwindPast(Nonnull<const Statement*> ast_node,
                   Nonnull<const Value*> result) -> ErrorOr<Success>;
 
-  // Resumes execution of a suspended continuation.
-  auto Resume(Nonnull<const ContinuationValue*> continuation)
-      -> ErrorOr<Success>;
-
-  // Suspends execution of the currently-executing continuation.
-  auto Suspend() -> ErrorOr<Success>;
-
   void Pop() { todo_.Pop(); }
 
   auto Count() const -> int { return todo_.Count(); }

+ 0 - 50
explorer/interpreter/interpreter.cpp

@@ -28,7 +28,6 @@
 #include "explorer/interpreter/action.h"
 #include "explorer/interpreter/action_stack.h"
 #include "explorer/interpreter/stack.h"
-#include "explorer/interpreter/stack_fragment.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Casting.h"
@@ -67,8 +66,6 @@ class Interpreter {
         trace_stream_(trace_stream),
         phase_(phase) {}
 
-  ~Interpreter();
-
   // Runs all the steps of `action`.
   // It's not safe to call `RunAllSteps()` or `result()` after an error.
   auto RunAllSteps(std::unique_ptr<Action> action) -> ErrorOr<Success>;
@@ -180,22 +177,10 @@ class Interpreter {
   Heap heap_;
   ActionStack todo_;
 
-  // The underlying states of continuation values. All StackFragments created
-  // during execution are tracked here, in order to safely deallocate the
-  // contents of any non-completed continuations at the end of execution.
-  std::vector<Nonnull<StackFragment*>> stack_fragments_;
-
   Nonnull<TraceStream*> trace_stream_;
   Phase phase_;
 };
 
-Interpreter::~Interpreter() {
-  // Clean up any remaining suspended continuations.
-  for (Nonnull<StackFragment*> fragment : stack_fragments_) {
-    fragment->Clear();
-  }
-}
-
 //
 // State Operations
 //
@@ -545,7 +530,6 @@ auto Interpreter::StepLocation() -> ErrorOr<Success> {
     case ExpressionKind::BoolTypeLiteral:
     case ExpressionKind::TypeTypeLiteral:
     case ExpressionKind::FunctionTypeLiteral:
-    case ExpressionKind::ContinuationTypeLiteral:
     case ExpressionKind::StringLiteral:
     case ExpressionKind::StringTypeLiteral:
     case ExpressionKind::ValueLiteral:
@@ -771,12 +755,10 @@ auto Interpreter::Convert(Nonnull<const Value*> value,
     case Value::Kind::ConstraintImplWitness:
     case Value::Kind::ParameterizedEntityName:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::VariableType:
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringType:
     case Value::Kind::StringValue:
     case Value::Kind::TypeOfMixinPseudoType:
@@ -1812,10 +1794,6 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
       CARBON_CHECK(act.pos() == 0);
       return todo_.FinishAction(arena_->New<TypeType>());
     }
-    case ExpressionKind::ContinuationTypeLiteral: {
-      CARBON_CHECK(act.pos() == 0);
-      return todo_.FinishAction(arena_->New<ContinuationType>());
-    }
     case ExpressionKind::StringLiteral:
       CARBON_CHECK(act.pos() == 0);
       // { {n :: C, E, F} :: S, H} -> { {n' :: C, E, F} :: S, H}
@@ -2248,34 +2226,6 @@ auto Interpreter::StepStmt() -> ErrorOr<Success> {
                     stmt.source_loc()));
         return todo_.UnwindPast(*function.body(), return_value);
       }
-    case StatementKind::Continuation: {
-      CARBON_CHECK(act.pos() == 0);
-      const auto& continuation = cast<Continuation>(stmt);
-      // Create a continuation object by creating a frame similar the
-      // way one is created in a function call.
-      auto* fragment = arena_->New<StackFragment>();
-      stack_fragments_.push_back(fragment);
-      todo_.InitializeFragment(*fragment, &continuation.body());
-      // Bind the continuation object to the continuation variable
-      todo_.Initialize(&cast<Continuation>(stmt),
-                       arena_->New<ContinuationValue>(fragment));
-      return todo_.FinishAction();
-    }
-    case StatementKind::Run: {
-      const auto& run = cast<Run>(stmt);
-      if (act.pos() == 0) {
-        // Evaluate the argument of the run statement.
-        return todo_.Spawn(std::make_unique<ExpressionAction>(&run.argument()));
-      } else if (act.pos() == 1) {
-        // Push the continuation onto the current stack.
-        return todo_.Resume(cast<const ContinuationValue>(act.results()[0]));
-      } else {
-        return todo_.FinishAction();
-      }
-    }
-    case StatementKind::Await:
-      CARBON_CHECK(act.pos() == 0);
-      return todo_.Suspend();
   }
 }
 

+ 0 - 6
explorer/interpreter/resolve_control_flow.cpp

@@ -124,16 +124,10 @@ static auto ResolveControlFlow(Nonnull<Statement*> statement,
       }
       return Success();
     }
-    case StatementKind::Continuation:
-      CARBON_RETURN_IF_ERROR(ResolveControlFlow(
-          &cast<Continuation>(*statement).body(), std::nullopt, std::nullopt));
-      return Success();
     case StatementKind::ExpressionStatement:
     case StatementKind::Assign:
     case StatementKind::IncrementDecrement:
     case StatementKind::VariableDefinition:
-    case StatementKind::Run:
-    case StatementKind::Await:
       return Success();
   }
 }

+ 0 - 17
explorer/interpreter/resolve_names.cpp

@@ -419,7 +419,6 @@ auto NameResolver::ResolveNames(Expression& expression,
     case ExpressionKind::BoolTypeLiteral:
     case ExpressionKind::BoolLiteral:
     case ExpressionKind::IntTypeLiteral:
-    case ExpressionKind::ContinuationTypeLiteral:
     case ExpressionKind::IntLiteral:
     case ExpressionKind::StringLiteral:
     case ExpressionKind::StringTypeLiteral:
@@ -626,22 +625,6 @@ auto NameResolver::ResolveNames(Statement& statement,
       }
       break;
     }
-    case StatementKind::Continuation: {
-      auto& continuation = cast<Continuation>(statement);
-      CARBON_RETURN_IF_ERROR(
-          enclosing_scope.Add(continuation.name(), &continuation,
-                              StaticScope::NameStatus::DeclaredButNotUsable));
-      StaticScope continuation_scope(&enclosing_scope);
-      CARBON_RETURN_IF_ERROR(ResolveNames(cast<Continuation>(statement).body(),
-                                          continuation_scope));
-      enclosing_scope.MarkUsable(continuation.name());
-      break;
-    }
-    case StatementKind::Run:
-      CARBON_RETURN_IF_ERROR(
-          ResolveNames(cast<Run>(statement).argument(), enclosing_scope));
-      break;
-    case StatementKind::Await:
     case StatementKind::Break:
     case StatementKind::Continue:
       break;

+ 0 - 4
explorer/interpreter/resolve_unformed.cpp

@@ -134,7 +134,6 @@ static auto ResolveUnformed(Nonnull<const Expression*> expression,
     case ExpressionKind::StringLiteral:
     case ExpressionKind::StringTypeLiteral:
     case ExpressionKind::TypeTypeLiteral:
-    case ExpressionKind::ContinuationTypeLiteral:
     case ExpressionKind::ValueLiteral:
     case ExpressionKind::IndexExpression:
     case ExpressionKind::CompoundMemberAccessExpression:
@@ -283,9 +282,6 @@ static auto ResolveUnformed(Nonnull<const Statement*> statement,
     }
     case StatementKind::Break:
     case StatementKind::Continue:
-    case StatementKind::Continuation:
-    case StatementKind::Run:
-    case StatementKind::Await:
     case StatementKind::For:
       // do nothing
       break;

+ 0 - 48
explorer/interpreter/stack_fragment.cpp

@@ -1,48 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "explorer/interpreter/stack_fragment.h"
-
-#include "common/check.h"
-#include "llvm/ADT/StringExtras.h"
-
-namespace Carbon {
-
-StackFragment::~StackFragment() {
-  CARBON_CHECK(reversed_todo_.empty())
-      << "All StackFragments must be empty before the Carbon program ends.";
-}
-
-void StackFragment::StoreReversed(
-    std::vector<std::unique_ptr<Action>> reversed_todo) {
-  CARBON_CHECK(reversed_todo_.empty());
-  reversed_todo_ = std::move(reversed_todo);
-}
-
-void StackFragment::RestoreTo(Stack<std::unique_ptr<Action>>& todo) {
-  while (!reversed_todo_.empty()) {
-    todo.Push(std::move(reversed_todo_.back()));
-    reversed_todo_.pop_back();
-  }
-}
-
-void StackFragment::Clear() {
-  // We destroy the underlying Actions explicitly to ensure they're
-  // destroyed in the correct order.
-  for (auto& action : reversed_todo_) {
-    action.reset();
-  }
-  reversed_todo_.clear();
-}
-
-void StackFragment::Print(llvm::raw_ostream& out) const {
-  out << "{";
-  llvm::ListSeparator sep(" :: ");
-  for (const std::unique_ptr<Action>& action : reversed_todo_) {
-    out << sep << *action;
-  }
-  out << "}";
-}
-
-}  // namespace Carbon

+ 0 - 51
explorer/interpreter/stack_fragment.h

@@ -1,51 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef CARBON_EXPLORER_INTERPRETER_STACK_FRAGMENT_H_
-#define CARBON_EXPLORER_INTERPRETER_STACK_FRAGMENT_H_
-
-#include <memory>
-#include <vector>
-
-#include "explorer/ast/value.h"
-#include "explorer/interpreter/action.h"
-#include "explorer/interpreter/stack.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace Carbon {
-
-// A continuation value behaves like a pointer to the underlying stack
-// fragment, which is exposed by `Stack()`.
-class StackFragment : public ContinuationValue::Representation {
- public:
-  // Constructs an empty StackFragment.
-  StackFragment() = default;
-
-  // Requires *this to be empty, because by the time we're tearing down the
-  // Arena, it's no longer safe to invoke ~Action.
-  ~StackFragment() override;
-
-  // Store the given partial todo stack in *this, which must currently be
-  // empty. The stack is represented with the top of the stack at the
-  // beginning of the vector, the reverse of the usual order.
-  void StoreReversed(std::vector<std::unique_ptr<Action>> reversed_todo);
-
-  // Restore the currently stored stack fragment to the top of `todo`,
-  // leaving *this empty.
-  void RestoreTo(Stack<std::unique_ptr<Action>>& todo);
-
-  // Destroy the currently stored stack fragment.
-  void Clear();
-
-  void Print(llvm::raw_ostream& out) const override;
-
- private:
-  // The todo stack of a suspended continuation, starting with the top
-  // Action.
-  std::vector<std::unique_ptr<Action>> reversed_todo_;
-};
-
-}  // namespace Carbon
-
-#endif  // CARBON_EXPLORER_INTERPRETER_STACK_FRAGMENT_H_

+ 0 - 36
explorer/interpreter/type_checker.cpp

@@ -97,7 +97,6 @@ static auto IsTypeOfType(Nonnull<const Value*> value) -> bool {
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue:
     case Value::Kind::ImplWitness:
@@ -116,7 +115,6 @@ static auto IsTypeOfType(Nonnull<const Value*> value) -> bool {
     case Value::Kind::NominalClassType:
     case Value::Kind::MixinPseudoType:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::StringType:
     case Value::Kind::StaticArrayType:
     case Value::Kind::TupleType:
@@ -159,7 +157,6 @@ static auto IsType(Nonnull<const Value*> value) -> bool {
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue:
     case Value::Kind::ImplWitness:
@@ -181,7 +178,6 @@ static auto IsType(Nonnull<const Value*> value) -> bool {
     case Value::Kind::NamedConstraintType:
     case Value::Kind::ConstraintType:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::VariableType:
     case Value::Kind::StringType:
     case Value::Kind::StaticArrayType:
@@ -230,7 +226,6 @@ static auto ExpectCompleteType(SourceLocation source_loc,
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue:
     case Value::Kind::ImplWitness:
@@ -250,7 +245,6 @@ static auto ExpectCompleteType(SourceLocation source_loc,
     case Value::Kind::FunctionType:
     case Value::Kind::StructType:
     case Value::Kind::ConstraintType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::VariableType:
     case Value::Kind::AssociatedConstant:
     case Value::Kind::TypeOfParameterizedEntityName:
@@ -344,7 +338,6 @@ static auto TypeContainsAuto(Nonnull<const Value*> type) -> bool {
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue:
     case Value::Kind::ImplWitness:
@@ -372,7 +365,6 @@ static auto TypeContainsAuto(Nonnull<const Value*> type) -> bool {
     case Value::Kind::NamedConstraintType:
     case Value::Kind::ConstraintType:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::AssociatedConstant:
       // These types can contain other types, but those types can't involve
       // `auto`.
@@ -1240,7 +1232,6 @@ auto TypeChecker::ArgumentDeduction::Deduce(Nonnull<const Value*> param,
       // are not deduced as part of this deduction step.
     case Value::Kind::StaticArrayType:
       // TODO: We could deduce the array type from an array or tuple argument.
-    case Value::Kind::ContinuationType:
     case Value::Kind::ChoiceType:
       // TODO: Choice types should be handled like other named declarations.
     case Value::Kind::ConstraintType:
@@ -1274,7 +1265,6 @@ auto TypeChecker::ArgumentDeduction::Deduce(Nonnull<const Value*> param,
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue: {
       // Argument deduction within the parameters of a parameterized class type
@@ -3810,7 +3800,6 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
     case ExpressionKind::BoolTypeLiteral:
     case ExpressionKind::StringTypeLiteral:
     case ExpressionKind::TypeTypeLiteral:
-    case ExpressionKind::ContinuationTypeLiteral:
       e->set_expression_category(ExpressionCategory::Value);
       e->set_static_type(arena_->New<TypeType>());
       return Success();
@@ -4673,26 +4662,6 @@ auto TypeChecker::TypeCheckStmt(Nonnull<Statement*> s,
       }
       return Success();
     }
-    case StatementKind::Continuation: {
-      auto& cont = cast<Continuation>(*s);
-      CARBON_RETURN_IF_ERROR(TypeCheckStmt(&cont.body(), impl_scope));
-      cont.set_static_type(arena_->New<ContinuationType>());
-      return Success();
-    }
-    case StatementKind::Run: {
-      auto& run = cast<Run>(*s);
-      CARBON_RETURN_IF_ERROR(TypeCheckExp(&run.argument(), impl_scope));
-      CARBON_ASSIGN_OR_RETURN(
-          Nonnull<Expression*> converted_argument,
-          ImplicitlyConvert("argument of `run`", impl_scope, &run.argument(),
-                            arena_->New<ContinuationType>()));
-      run.set_argument(converted_argument);
-      return Success();
-    }
-    case StatementKind::Await: {
-      // Nothing to do here.
-      return Success();
-    }
   }
 }
 
@@ -4754,9 +4723,6 @@ auto TypeChecker::ExpectReturnOnAllPaths(
     case StatementKind::ReturnVar:
     case StatementKind::ReturnExpression:
       return Success();
-    case StatementKind::Continuation:
-    case StatementKind::Run:
-    case StatementKind::Await:
     case StatementKind::Assign:
     case StatementKind::IncrementDecrement:
     case StatementKind::ExpressionStatement:
@@ -5895,7 +5861,6 @@ static auto IsValidTypeForAliasTarget(Nonnull<const Value*> type) -> bool {
     case Value::Kind::BindingPlaceholderValue:
     case Value::Kind::AddrValue:
     case Value::Kind::AlternativeConstructorValue:
-    case Value::Kind::ContinuationValue:
     case Value::Kind::StringValue:
     case Value::Kind::UninitializedValue:
       CARBON_FATAL() << "type of alias target is not a type";
@@ -5912,7 +5877,6 @@ static auto IsValidTypeForAliasTarget(Nonnull<const Value*> type) -> bool {
     case Value::Kind::TupleType:
     case Value::Kind::NominalClassType:
     case Value::Kind::ChoiceType:
-    case Value::Kind::ContinuationType:
     case Value::Kind::StringType:
     case Value::Kind::AssociatedConstant:
       return false;

+ 0 - 1
explorer/interpreter/type_structure.cpp

@@ -82,7 +82,6 @@ struct TypeStructureBuilder {
   void Visit(const VTable&) {}
   void Visit(const FunctionType::GenericParameter&) {}
   void Visit(const NamedElement&) {}
-  void Visit(Nonnull<const ContinuationValue::Representation*>) {}
 
   // Constraint types can contain mentions of VariableTypes, but they aren't
   // deducible so it's not important to look for them.

+ 0 - 8
explorer/syntax/lexer.lpp

@@ -41,7 +41,6 @@ API                   "api"
 ARROW                 "->"
 AS                    "as"
 AUTO                  "auto"
-AWAIT                 "__await"
 BASE                  "base"
 BOOL                  "bool"
 BREAK                 "break"
@@ -54,8 +53,6 @@ COLON                 ":"
 COLON_BANG            ":!"
 COMMA                 ","
 CONSTRAINT            "constraint"
-CONTINUATION          "__continuation"
-CONTINUATION_TYPE     "__Continuation"
 CONTINUE              "continue"
 DEFAULT               "default"
 DESTRUCTOR            "destructor"
@@ -114,7 +111,6 @@ RETURNED              "returned"
 RIGHT_CURLY_BRACE     "}"
 RIGHT_PARENTHESIS     ")"
 RIGHT_SQUARE_BRACKET  "]"
-RUN                   "__run"
 SELF                  "Self"
 SEMICOLON             ";"
 SLASH                 "/"
@@ -164,7 +160,6 @@ operand_start         [(A-Za-z0-9_\"]
 {ARROW}                 { return CARBON_SIMPLE_TOKEN(ARROW);                 }
 {AS}                    { return CARBON_SIMPLE_TOKEN(AS);                    }
 {AUTO}                  { return CARBON_SIMPLE_TOKEN(AUTO);                  }
-{AWAIT}                 { return CARBON_SIMPLE_TOKEN(AWAIT);                 }
 {BASE}                  { return CARBON_SIMPLE_TOKEN(BASE);                  }
 {BOOL}                  { return CARBON_SIMPLE_TOKEN(BOOL);                  }
 {BREAK}                 { return CARBON_SIMPLE_TOKEN(BREAK);                 }
@@ -177,8 +172,6 @@ operand_start         [(A-Za-z0-9_\"]
 {COLON}                 { return CARBON_SIMPLE_TOKEN(COLON);                 }
 {COMMA}                 { return CARBON_SIMPLE_TOKEN(COMMA);                 }
 {CONSTRAINT}            { return CARBON_SIMPLE_TOKEN(CONSTRAINT);            }
-{CONTINUATION_TYPE}     { return CARBON_SIMPLE_TOKEN(CONTINUATION_TYPE);     }
-{CONTINUATION}          { return CARBON_SIMPLE_TOKEN(CONTINUATION);          }
 {CONTINUE}              { return CARBON_SIMPLE_TOKEN(CONTINUE);              }
 {DEFAULT}               { return CARBON_SIMPLE_TOKEN(DEFAULT);               }
 {DESTRUCTOR}            { return CARBON_SIMPLE_TOKEN(DESTRUCTOR);            }
@@ -234,7 +227,6 @@ operand_start         [(A-Za-z0-9_\"]
 {PLUS}                  { return CARBON_SIMPLE_TOKEN(PLUS);                  }
 {RETURNED}              { return CARBON_SIMPLE_TOKEN(RETURNED);              }
 {RETURN}                { return CARBON_SIMPLE_TOKEN(RETURN);                }
-{RUN}                   { return CARBON_SIMPLE_TOKEN(RUN);                   }
 {SELF}                  { return CARBON_SIMPLE_TOKEN(SELF);                  }
 {SEMICOLON}             { return CARBON_SIMPLE_TOKEN(SEMICOLON);             }
 {SLASH_EQUAL}           { return CARBON_SIMPLE_TOKEN(SLASH_EQUAL);           }

+ 0 - 15
explorer/syntax/parser.ypp

@@ -217,7 +217,6 @@
   ARROW
   AS
   AUTO
-  AWAIT
   BASE
   BOOL
   BREAK
@@ -230,8 +229,6 @@
   COLON_BANG
   COMMA
   CONSTRAINT
-  CONTINUATION
-  CONTINUATION_TYPE
   CONTINUE
   DEFAULT
   DESTRUCTOR
@@ -291,7 +288,6 @@
   RIGHT_CURLY_BRACE
   RIGHT_PARENTHESIS
   RIGHT_SQUARE_BRACKET
-  RUN
   SELF
   SEMICOLON
   SLASH
@@ -416,8 +412,6 @@ primary_expression:
     { $$ = arena->New<BoolTypeLiteral>(context.source_loc()); }
 | TYPE
     { $$ = arena->New<TypeTypeLiteral>(context.source_loc()); }
-| CONTINUATION_TYPE
-    { $$ = arena->New<ContinuationTypeLiteral>(context.source_loc()); }
 | paren_expression { $$ = $[paren_expression]; }
 | struct_literal { $$ = $[struct_literal]; }
 | struct_type_literal { $$ = $[struct_type_literal]; }
@@ -1124,15 +1118,6 @@ statement:
       $$ = arena->New<Match>(context.source_loc(), $[expression],
                              $[clause_list]);
     }
-| CONTINUATION identifier block
-    {
-      $$ = arena->New<Continuation>(context.source_loc(), $[identifier],
-                                    $[block]);
-    }
-| RUN expression SEMICOLON
-    { $$ = arena->New<Run>(context.source_loc(), $[expression]); }
-| AWAIT SEMICOLON
-    { $$ = arena->New<Await>(context.source_loc()); }
 | FOR LEFT_PARENTHESIS variable_declaration IN type_expression RIGHT_PARENTHESIS
   block
     {

+ 0 - 26
explorer/testdata/experimental_continuation/await_maintains_scope.carbon

@@ -1,26 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 3
-
-package ExplorerTest api;
-
-// Test access to block-scoped variables upon resuming a continuation.
-
-fn Main() -> i32 {
-  var y: i32 = 0;
-  __continuation k {
-    var x: i32 = 0;
-    x = x + 1;
-    __await;
-    x = x + 2;
-    y = x;
-  }
-  __run k;
-  __run k;
-  return y;
-}

+ 0 - 31
explorer/testdata/experimental_continuation/convert_run.carbon

@@ -1,31 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 3
-
-package ExplorerTest api;
-
-class Wrap(T:! type) {
-  var v: T;
-}
-fn MakeWrap[T:! type](x: T) -> Wrap(T) { return {.v = x}; }
-
-impl forall [T:! type] Wrap(T) as ImplicitAs(T) {
-  fn Convert[self: Self]() -> T {
-    return self.v;
-  }
-}
-
-fn Main() -> i32 {
-  var n: i32 = 1;
-  __continuation k {
-    n = n + 1;
-  }
-  n = 2;
-  __run MakeWrap(k);
-  return n;
-}

+ 0 - 20
explorer/testdata/experimental_continuation/creation_is_noop.carbon

@@ -1,20 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 0
-
-package ExplorerTest api;
-
-// Test that creating a continuation doesn't do anything.
-
-fn Main() -> i32 {
-  var x: i32 = 0;
-  __continuation k {
-    x = x + 1;
-  }
-  return x;
-}

+ 0 - 18
explorer/testdata/experimental_continuation/fail_auto_return_await.carbon

@@ -1,18 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{not} %{explorer-run}
-// RUN: %{not} %{explorer-run-trace}
-
-package ExplorerTest api;
-
-fn f() -> auto {
-   // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_auto_return_await.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
-   __await;
-}
-
-fn Main() -> i32 {
-  return 0;
-}

+ 0 - 17
explorer/testdata/experimental_continuation/fail_continuation_syntax.carbon

@@ -1,17 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{not} %{explorer-run}
-// RUN: %{not} %{explorer-run-trace}
-
-package ExplorerTest api;
-
-fn Main() -> i32 {
-  var x: i32 = 0;
-  // CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_continuation_syntax.carbon:[[@LINE+1]]: syntax error, unexpected identifier, expecting LEFT_CURLY_BRACE
-  __continuation k x = 3;
-  __run k;
-  return x;
-}

+ 0 - 29
explorer/testdata/experimental_continuation/fail_lifetime.carbon

@@ -1,29 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{not} %{explorer-run}
-// RUN: %{not} %{explorer-run-trace}
-
-package ExplorerTest api;
-
-// Test that the read from x triggers an error because x is dead.
-// This test also demonstrates how by-reference free-variable capture
-// is dangerous and can happen inside continuations.
-
-fn capture() -> __Continuation {
-  var x: i32 = 1;
-  __continuation k {
-    // CHECK:STDERR: RUNTIME ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_lifetime.carbon:[[@LINE+1]]: undefined behavior: access to dead value 1
-    var y: i32 = x;
-  }
-  return k;
-}
-
-fn Main() -> i32 {
-  var k: __Continuation = capture();
-  // error, lifetime of x is over
-  __run k;
-  return 0;
-}

+ 0 - 20
explorer/testdata/experimental_continuation/fail_recursive_continuation.carbon

@@ -1,20 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{not} %{explorer-run}
-// RUN: %{not} %{explorer-run-trace}
-
-package ExplorerTest api;
-
-fn f() {
-  __continuation k {
-  // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_recursive_continuation.carbon:[[@LINE+1]]: 'k' is not usable until after it has been completely declared
-  __run k;
-  }
-}
-
-fn Main() -> i32 {
-  return 0;
-}

+ 0 - 18
explorer/testdata/experimental_continuation/fail_return_in_continuation.carbon

@@ -1,18 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{not} %{explorer-run}
-// RUN: %{not} %{explorer-run-trace}
-
-package ExplorerTest api;
-
-fn Main() -> i32 {
-  var x: i32 = 0;
-  __continuation k {
-    x = x + 1;
-    // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_return_in_continuation.carbon:[[@LINE+1]]: return is not within a function body
-    return x;
-  }
-}

+ 0 - 40
explorer/testdata/experimental_continuation/recursive.carbon

@@ -1,40 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 10
-
-package ExplorerTest api;
-
-// Test recursive functions inside continuations.
-
-var current: i32 = 0;
-
-fn CountUpTo(x: i32) -> i32 {
-  if (x == 0) {
-    current = 0;
-    __await;
-    return 0;
-  } else {
-    current = 1 + CountUpTo(x - 1);
-    __await;
-    return current;
-  }
-}
-
-fn Main() -> i32 {
-  __continuation k {
-    CountUpTo(5);
-  }
-  var sum: i32 = 0;
-  var count: i32 = 5;
-  while (count != 0) {
-    __run k;
-    sum = sum + current;
-    count = count - 1;
-  }
-  return sum;
-}

+ 0 - 21
explorer/testdata/experimental_continuation/run.carbon

@@ -1,21 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 1
-
-package ExplorerTest api;
-
-// Test creating and running a continuation.
-
-fn Main() -> i32 {
-  var x: i32 = 0;
-  __continuation k {
-    x = x + 1;
-  }
-  __run k;
-  return x;
-}

+ 0 - 25
explorer/testdata/experimental_continuation/run_with_await.carbon

@@ -1,25 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 3
-
-package ExplorerTest api;
-
-// Test pausing a continuation with `__await` and restarting it with
-// `__run`.
-
-fn Main() -> i32 {
-  var x: i32 = 0;
-  __continuation k {
-    x = x + 1;
-    __await;
-    x = x + 2;
-  }
-  __run k;
-  __run k;
-  return x;
-}

+ 0 - 31
explorer/testdata/experimental_continuation/shallow_copy.carbon

@@ -1,31 +0,0 @@
-// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-// AUTOUPDATE
-// RUN: %{explorer-run}
-// RUN: %{explorer-run-trace}
-// CHECK:STDOUT: result: 3
-
-package ExplorerTest api;
-
-// Assignment for continuations is shallow, so `k2` refers to the same
-// continuation as `k1`.
-
-var x: i32 = 0;
-
-fn Foo() {
-  x = x + 1;
-  __await;
-  x = x + 2;
-}
-
-fn Main() -> i32 {
-  __continuation k1 {
-    Foo();
-  }
-  var k2: __Continuation = k1;
-  __run k1;
-  __run k2;
-  return x;
-}