write_from_function.carbon 461 B

12345678910111213141516171819202122
  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. // CHECK:STDOUT: result: 0
  7. package ExplorerTest api;
  8. // Test that mutations to a global variable in one function is visible
  9. // in another function.
  10. var flag: i32 = 1;
  11. fn flipFlag() {
  12. flag = 0;
  13. }
  14. fn Main() -> i32 {
  15. flipFlag();
  16. return flag;
  17. }