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