You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make named constraint eval to a FacetType with itself in it (#6308)
This requires declared FacetTypes to hold NamedConstraintIds (along with
a specific) that are named in an extend or impls requirement. We add
support to stringify and formatter to display the named constraints in
the facet type, and special case when a facet type contains a single
extend named constraint, like we did for a single extend interface.
This means that `RequireIndentifiedFacetType` can now fail, if the facet
type contains a forward-declared named constraint. Add the appropriate
diagnostics for each call to this function, and note the ones that
should change to `RequireCompleteFacetType` in the future with TODOs.
We also add tests for using facet types that can or can't be identified,
or completed, with named constraints in them.
Copy file name to clipboardExpand all lines: toolchain/check/testdata/facet/fail_incomplete.carbon
+69-12Lines changed: 69 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,9 @@
10
10
// TIP: To dump output, run:
11
11
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/fail_incomplete.carbon
12
12
13
+
// --- fail_incomplete_interface.carbon
14
+
library "[[@TEST_NAME]]";
15
+
13
16
interfaceA;
14
17
interfaceB {}
15
18
class C {}
@@ -18,31 +21,85 @@ fn G[T:! A](t: T) {}
18
21
fnH[T:! A & B](t: T) {}
19
22
20
23
fnF() {
21
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE+4]]:17: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
22
-
// CHECK:STDERR: ({} as C) as (C as A);
23
-
// CHECK:STDERR: ^~~~~~
24
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+4]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
25
+
// CHECK:STDERR: C as A;
26
+
// CHECK:STDERR: ^~~~~~
27
+
// CHECK:STDERR:
28
+
C asA;
29
+
30
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+4]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
31
+
// CHECK:STDERR: C as (A & B);
32
+
// CHECK:STDERR: ^~~~~~~~~~~~
33
+
// CHECK:STDERR:
34
+
C as (A & B);
35
+
36
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
37
+
// CHECK:STDERR: G({} as C);
38
+
// CHECK:STDERR: ^~~~~~~~~~
39
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE-19]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
40
+
// CHECK:STDERR: fn G[T:! A](t: T) {}
41
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
42
+
// CHECK:STDERR:
43
+
G({} asC);
44
+
45
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
46
+
// CHECK:STDERR: H({} as C);
47
+
// CHECK:STDERR: ^~~~~~~~~~
48
+
// CHECK:STDERR: fail_incomplete_interface.carbon:[[@LINE-27]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
49
+
// CHECK:STDERR: fn H[T:! A & B](t: T) {}
50
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
51
+
// CHECK:STDERR:
52
+
H({} asC);
53
+
}
54
+
55
+
// --- fail_incomplete_constraint.carbon
56
+
library "[[@TEST_NAME]]";
57
+
58
+
constraint A;
59
+
interfaceB {}
60
+
class C {}
61
+
62
+
fnG[T:! A](t: T) {}
63
+
fnH[T:! A & B](t: T) {}
64
+
65
+
fnF() {
66
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+7]]:3: error: facet type `A` is incomplete [ImplLookupInIncompleteFacetType]
67
+
// CHECK:STDERR: C as A;
68
+
// CHECK:STDERR: ^~~~~~
69
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-11]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere]
70
+
// CHECK:STDERR: constraint A;
71
+
// CHECK:STDERR: ^~~~~~~~~~~~~
24
72
// CHECK:STDERR:
25
-
({} asC)as(C asA);
73
+
CasA;
26
74
27
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE+4]]:17: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
28
-
// CHECK:STDERR: ({} as C) as (C as (A & B));
29
-
// CHECK:STDERR: ^~~~~~~~~~~~
75
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+7]]:3: error: facet type `B & A` is incomplete [ImplLookupInIncompleteFacetType]
76
+
// CHECK:STDERR: C as (A & B);
77
+
// CHECK:STDERR: ^~~~~~~~~~~~
78
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-20]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere]
79
+
// CHECK:STDERR: constraint A;
80
+
// CHECK:STDERR: ^~~~~~~~~~~~~
30
81
// CHECK:STDERR:
31
-
({} asC)as (C as (A & B));
82
+
Cas (A & B);
32
83
33
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
84
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+10]]:3: error: facet type `A` is incomplete [ImplLookupInIncompleteFacetType]
34
85
// CHECK:STDERR: G({} as C);
35
86
// CHECK:STDERR: ^~~~~~~~~~
36
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE-19]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
87
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-29]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere]
88
+
// CHECK:STDERR: constraint A;
89
+
// CHECK:STDERR: ^~~~~~~~~~~~~
90
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-28]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
37
91
// CHECK:STDERR: fn G[T:! A](t: T) {}
38
92
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
39
93
// CHECK:STDERR:
40
94
G({} asC);
41
95
42
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
96
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE+10]]:3: error: facet type `B & A` is incomplete [ImplLookupInIncompleteFacetType]
43
97
// CHECK:STDERR: H({} as C);
44
98
// CHECK:STDERR: ^~~~~~~~~~
45
-
// CHECK:STDERR: fail_incomplete.carbon:[[@LINE-27]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
99
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-41]]:1: note: constraint was forward declared here [NamedConstraintForwardDeclaredHere]
100
+
// CHECK:STDERR: constraint A;
101
+
// CHECK:STDERR: ^~~~~~~~~~~~~
102
+
// CHECK:STDERR: fail_incomplete_constraint.carbon:[[@LINE-39]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
0 commit comments