fail_no_args.carbon 697 B

123456789101112131415161718192021222324252627
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. class Point(T:! type) {
  8. fn Origin(zero: T) -> Point(T) {
  9. return {.x = zero, .y = zero};
  10. }
  11. // Error: wrote `Point` instead of `Point(T)`, `Point` by itself is not a type.
  12. // CHECK:STDERR: COMPILATION ERROR: fail_no_args.carbon:[[@LINE+1]]: 'Point' must be given an argument list
  13. fn GetX[self: Point]() -> T {
  14. return self.x;
  15. }
  16. var x: T;
  17. var y: T;
  18. }
  19. fn Main() -> i32 {
  20. var p: Point(i32) = Point(i32).Origin(0);
  21. return p.GetX();
  22. }