fail_match_in_deduction.carbon 1.0 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. // AUTOUPDATE
  6. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. // TODO: Should this work?
  9. package ExplorerTest api;
  10. interface Vector {
  11. let Dim:! i32;
  12. }
  13. external impl (i32, i32, i32) as Vector where .Dim = 3 {}
  14. class Point(Scalar:! type, Dim:! i32) {}
  15. fn F[Scalar:! type, V:! Vector where .Dim == 3](p: Point(Scalar, V.Dim), v: V) {}
  16. fn G[Scalar:! type](p: Point(Scalar, 3)) {}
  17. fn H[V:! Vector where .Dim == 3](v: V) {
  18. var p: Point(i32, V.Dim) = {};
  19. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_match_in_deduction.carbon:[[@LINE+1]]: mismatch in non-type values, `(V).(Vector.Dim)` != `3`
  20. G(p);
  21. }
  22. fn Main() -> i32 {
  23. var p: Point(i32, 3) = {};
  24. // Deduce Point(Scalar, V.Dim) from Point(i32, 3).
  25. F(p, (0, 0, 0));
  26. // Deduce Point(Scalar, 3) from Point(i32, V.Dim).
  27. H((0, 0, 0));
  28. return 0;
  29. }