fun2.carbon 476 B

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