global_variable2.carbon 428 B

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