fail_no_args.carbon 790 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. // AUTOUPDATE
  6. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. class Point(T:! Type) {
  10. fn Origin(zero: T) -> Point(T) {
  11. return {.x = zero, .y = zero};
  12. }
  13. // Error: wrote `Point` instead of `Point(T)`, `Point` by itself is not a type.
  14. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_no_args.carbon:[[@LINE+1]]: Expected a type, but got Point
  15. fn GetX[me: Point]() -> T {
  16. return me.x;
  17. }
  18. var x: T;
  19. var y: T;
  20. }
  21. fn Main() -> i32 {
  22. var p: Point(i32) = Point(i32).Origin(0);
  23. return p.GetX();
  24. }