pinned_value_copied.carbon 672 B

12345678910111213141516171819202122232425262728
  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. fn Main() -> i32 {
  8. var a: i32 = 1;
  9. let a_pinned: i32 = a;
  10. let a_pinned_copy: i32 = a_pinned;
  11. // OK: Value unused after being mutated.
  12. a = 2;
  13. Print("a: {0}", a);
  14. // OK: Value was copied from `a_pinned`, and reflects previous value.
  15. // TODO: Avoid value->value copy when possible.
  16. Print("a_pinned2: {0}", a_pinned_copy);
  17. return 0;
  18. }
  19. // CHECK:STDOUT: a: 2
  20. // CHECK:STDOUT: a_pinned2: 1
  21. // CHECK:STDOUT: result: 0