experimental_continuation5.carbon 475 B

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