experimental_continuation5.carbon 437 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. // Test access to block-scoped variables upon resuming a continuation.
  5. fn main() -> Int {
  6. var y: Int = 0;
  7. __continuation k {
  8. var x: Int = 0;
  9. x = x + 1;
  10. __await;
  11. x = x + 2;
  12. y = x;
  13. }
  14. __run k;
  15. __run k;
  16. return y;
  17. }