for_loop_auto.carbon 615 B

123456789101112131415161718192021222324
  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. //
  5. // AUTOUPDATE
  6. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: HALLO WELT 0
  9. // CHECK:STDOUT: HALLO WELT 1
  10. // CHECK:STDOUT: HALLO WELT 2
  11. // CHECK:STDOUT: HALLO WELT 3
  12. // CHECK:STDOUT: result: 4
  13. package ExplorerTest api;
  14. fn Main() -> i32 {
  15. var ar: [i32; 4] = (0, 1, 2, 3);
  16. var count: i32 = 0;
  17. for (x: auto in ar) {
  18. Print("HALLO WELT {0}", x);
  19. count = count + 1;
  20. }
  21. return count;
  22. }