global_variable2.carbon 396 B

1234567891011121314151617
  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 that mutations to a global variable in one function is visible
  5. // in another function.
  6. var flag: Int = 1;
  7. fn flipFlag() -> () {
  8. flag = 0;
  9. }
  10. fn main() -> Int {
  11. flipFlag();
  12. return flag;
  13. }