Make continuations consistently "shallow" (#874)

Prior to this change, `__await` would make a deep copy of the continuation stack, but shallow-copy the individual stack frames within it. As a result, continuations appeared to have shallow semantics so long as the continuation stack had only a single frame.

This change also removes an obsolete test from the brief period when we intended continuations to have deep-copy semantics, which has been passing basically by accident.
This commit is contained in:
Geoff Romer
2021-10-11 14:57:09 -07:00
committed by GitHub
parent 9211c98951
commit d177a08e01
5 changed files with 34 additions and 52 deletions
+3 -3
View File
@@ -292,7 +292,7 @@ void Value::Print(llvm::raw_ostream& out) const {
case Value::Kind::ContinuationValue: {
out << "{";
llvm::ListSeparator sep(" :: ");
for (Nonnull<Frame*> frame : cast<ContinuationValue>(*this).Stack()) {
for (Nonnull<Frame*> frame : *cast<ContinuationValue>(*this).Stack()) {
out << sep << *frame;
}
out << "}";
@@ -352,8 +352,8 @@ auto CopyVal(Nonnull<Arena*> arena, Nonnull<const Value*> val,
case Value::Kind::PointerValue:
return arena->New<PointerValue>(cast<PointerValue>(*val).Val());
case Value::Kind::ContinuationValue:
// Copying a continuation is "shallow".
return val;
return arena->New<ContinuationValue>(
cast<ContinuationValue>(*val).Stack());
case Value::Kind::FunctionType: {
const auto& fn_type = cast<FunctionType>(*val);
return arena->New<FunctionType>(