write_from_function.carbon 462 B

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