fail_self_with_arg.carbon 849 B

12345678910111213141516171819202122232425262728293031
  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. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. class Point(T:! type) {
  10. // Error: wrote `Self(T)` instead of `Self`.
  11. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_self_with_arg.carbon:[[@LINE+1]]: in call `Self(T)`, expected callee to be a function, found `type`
  12. fn Origin(zero: T) -> Self(T) {
  13. return {.x = zero, .y = zero};
  14. }
  15. // Error: wrote `Self(T)` instead of `Self`.
  16. fn GetX[self: Self(T)]() -> T {
  17. return self.x;
  18. }
  19. var x: T;
  20. var y: T;
  21. }
  22. fn Main() -> i32 {
  23. var p: Point(i32) = Point(i32).Origin(0);
  24. return p.GetX();
  25. }