experimental_continuation4.6c 463 B

12345678910111213141516171819
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. // Assignment for continuations is shallow, so `k2` refers to the same
  5. // continuation as `k1`.
  6. fn main() -> Int {
  7. var Int x = 0;
  8. __continuation k1 {
  9. x = x + 1;
  10. __await;
  11. x = x + 2;
  12. }
  13. var __Continuation k2 = k1;
  14. __run k1;
  15. __run k2;
  16. return x;
  17. }