fail_match_in_deduction.carbon 950 B

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