fail_implied_constraints.carbon 990 B

123456789101112131415161718192021222324252627282930313233
  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. interface X(T:! Type) {}
  10. interface Y(T:! Type) {
  11. let M:! X(T);
  12. }
  13. interface Z {
  14. // We reject this even though it is the responsibility of the `impl as Z` to
  15. // provide a type `N` such that `i32 is X(N)`. We might want to treat this as
  16. // an implied constraint and allow this in the future.
  17. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_implied_constraints.carbon:[[@LINE+1]]: could not find implementation of interface X(T = N) for i32
  18. let N:! Y(.Self) where .M = i32;
  19. }
  20. impl i32 as X(i32) {}
  21. impl i32 as Y(i32) where .M = i32 {}
  22. impl i32 as Z where .N = i32 {}
  23. fn F[A:! Z](a: A) -> A { return a; }
  24. fn Main() -> i32 {
  25. return F(0);
  26. }