arrow.carbon 578 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 Foo api;
  7. class X {
  8. fn F[self: Self]() -> i32 { return self.n; }
  9. var n: i32;
  10. }
  11. fn Main() -> i32 {
  12. var v: X = {.n = 1};
  13. let p: X* = &v;
  14. Print("{0}", p->n);
  15. Print("{0}", p->(X.n));
  16. Print("{0}", p->F());
  17. Print("{0}", p->(X.F)());
  18. return 0;
  19. }
  20. // CHECK:STDOUT: 1
  21. // CHECK:STDOUT: 1
  22. // CHECK:STDOUT: 1
  23. // CHECK:STDOUT: 1
  24. // CHECK:STDOUT: result: 0