struct_alias.carbon 843 B

1234567891011121314151617181920212223242526272829
  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. // RUN: %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. // CHECK: ab.a: 2
  11. // CHECK: ab.b: 1
  12. // CHECK: ba.a: 2
  13. // CHECK: ba.b: 1
  14. // CHECK: result: 0
  15. package ExplorerTest api;
  16. alias AB = {.a: i32, .b: i32};
  17. alias BA = {.b: i32, .a: i32};
  18. fn Main() -> i32 {
  19. var ab: AB = {.b = 1, .a = 2};
  20. var ba: BA = ab;
  21. Print("ab.a: {0}", ab.a);
  22. Print("ab.b: {0}", ab.b);
  23. Print("ba.a: {0}", ba.a);
  24. Print("ba.b: {0}", ba.b);
  25. return 0;
  26. }