fun2.carbon 517 B

1234567891011121314151617181920
  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. // This tests the call-by-value aspect of parameter passing.
  6. // This makes sure that when the value in `x` dies,
  7. // it does not cause the value in `a` to also die.
  8. fn f(x: i32) -> i32 {
  9. return 0;
  10. }
  11. fn main() -> i32 {
  12. var a: i32 = 0; var b: i32 = 1;
  13. f(a);
  14. b = a;
  15. return b;
  16. }