assign_builtin.carbon 571 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. // CHECK:STDOUT: Before: 1
  7. // CHECK:STDOUT: Interface: 2
  8. // CHECK:STDOUT: Op: 3
  9. // CHECK:STDOUT: result: 0
  10. package ExplorerTest api;
  11. class C {
  12. var n: i32;
  13. }
  14. fn Main() -> i32 {
  15. var c: C = {.n = 1};
  16. Print("Before: {0}", c.n);
  17. c.(AssignWith({.n: i32}).Op)({.n = 2});
  18. Print("Interface: {0}", c.n);
  19. c = {.n = 3};
  20. Print("Op: {0}", c.n);
  21. return 0;
  22. }