param_lifetime.carbon 553 B

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