struct_alias.carbon 625 B

1234567891011121314151617181920212223242526
  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. alias AB = {.a: i32, .b: i32};
  8. alias BA = {.b: i32, .a: i32};
  9. fn Main() -> i32 {
  10. var ab: AB = {.b = 1, .a = 2};
  11. var ba: BA = ab;
  12. Print("ab.a: {0}", ab.a);
  13. Print("ab.b: {0}", ab.b);
  14. Print("ba.a: {0}", ba.a);
  15. Print("ba.b: {0}", ba.b);
  16. return 0;
  17. }
  18. // CHECK:STDOUT: ab.a: 2
  19. // CHECK:STDOUT: ab.b: 1
  20. // CHECK:STDOUT: ba.a: 2
  21. // CHECK:STDOUT: ba.b: 1
  22. // CHECK:STDOUT: result: 0