mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
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:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user