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