fail_indirectly_equal.carbon 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // RUN: %{not} %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. package ExplorerTest api;
  11. interface A {
  12. let T:! Type;
  13. }
  14. fn F1[T:! A where .T == i32](x: T.T) -> i32 {
  15. // OK: one equality.
  16. return x;
  17. }
  18. fn F2[U:! A where .T == i32](x: i32) -> U.T {
  19. // OK: one equality.
  20. return x;
  21. }
  22. fn F3[T:! A where .T == i32, U:! A where .T == i32](x: T.T) -> U.T {
  23. // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_indirectly_equal.carbon:[[@LINE+1]]: type error in return value: '(T:! A where .Self.T == i32).T' is not implicitly convertible to '(U:! A where .Self.T == i32).T'
  24. return x;
  25. }
  26. external impl i32 as A where .T == i32 {}
  27. fn Main() -> i32 {
  28. return F3(0);
  29. }