Skip to content

Commit 1a7c1a1

Browse files
authored
Add some failing tests with cycles and self-referential facet types (#5674)
Most of these tests should pass but don't, though one fails but in the wrong way.
1 parent 80529aa commit 1a7c1a1

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

toolchain/check/testdata/facet/facet_assoc_const.carbon

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,80 @@ interface N {
360360
// CHECK:STDERR:
361361
fn F(T:! N where .Y = {.a = {}} and .Y = {.a = ()}) {}
362362

363+
// --- fail_todo_cycle_through_self_reference.carbon
364+
library "[[@TEST_NAME]]";
365+
366+
interface Z {
367+
let T:! type;
368+
// TODO: This should not be an error.
369+
//
370+
// CHECK:STDERR: fail_todo_cycle_through_self_reference.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `Z` [IncompleteTypeInAssociatedConstantDecl]
371+
// CHECK:STDERR: let U:! Z;
372+
// CHECK:STDERR: ^
373+
// CHECK:STDERR: fail_todo_cycle_through_self_reference.carbon:[[@LINE-7]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition]
374+
// CHECK:STDERR: interface Z {
375+
// CHECK:STDERR: ^~~~~~~~~~~~~
376+
// CHECK:STDERR:
377+
let U:! Z;
378+
}
379+
380+
// TODO: Should be diagnosed as a cycle.
381+
fn F(A:! Z where .T = .U.T and .U = .Self) {}
382+
383+
// --- fail_todo_reference_same_constant_in_different_self.carbon
384+
library "[[@TEST_NAME]]";
385+
386+
interface Z {
387+
let T:! type;
388+
// TODO: This should not be an error.
389+
//
390+
// CHECK:STDERR: fail_todo_reference_same_constant_in_different_self.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `Z` [IncompleteTypeInAssociatedConstantDecl]
391+
// CHECK:STDERR: let U:! Z;
392+
// CHECK:STDERR: ^
393+
// CHECK:STDERR: fail_todo_reference_same_constant_in_different_self.carbon:[[@LINE-7]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition]
394+
// CHECK:STDERR: interface Z {
395+
// CHECK:STDERR: ^~~~~~~~~~~~~
396+
// CHECK:STDERR:
397+
let U:! Z;
398+
}
399+
400+
// TODO: Should not be diagnosed as a cycle, once the incorrect failure above is
401+
// fixed.
402+
fn F(A:! Z where .T = (), B:! Z where .T = .U.T and .U = A) {}
403+
404+
// --- fail_todo_non_cycle_with_self_reference.carbon
405+
library "[[@TEST_NAME]]";
406+
407+
interface Z {
408+
// TODO: This should not be an error.
409+
//
410+
// CHECK:STDERR: fail_todo_non_cycle_with_self_reference.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `Z` [IncompleteTypeInAssociatedConstantDecl]
411+
// CHECK:STDERR: let T:! Z;
412+
// CHECK:STDERR: ^
413+
// CHECK:STDERR: fail_todo_non_cycle_with_self_reference.carbon:[[@LINE-6]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition]
414+
// CHECK:STDERR: interface Z {
415+
// CHECK:STDERR: ^~~~~~~~~~~~~
416+
// CHECK:STDERR:
417+
let T:! Z;
418+
let U:! type;
419+
// TODO: This should not be an error.
420+
//
421+
// CHECK:STDERR: fail_todo_non_cycle_with_self_reference.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `Z` [IncompleteTypeInAssociatedConstantDecl]
422+
// CHECK:STDERR: let V:! Z;
423+
// CHECK:STDERR: ^
424+
// CHECK:STDERR: fail_todo_non_cycle_with_self_reference.carbon:[[@LINE-17]]:1: note: interface is currently being defined [InterfaceIncompleteWithinDefinition]
425+
// CHECK:STDERR: interface Z {
426+
// CHECK:STDERR: ^~~~~~~~~~~~~
427+
// CHECK:STDERR:
428+
let V:! Z;
429+
}
430+
431+
// TODO: Should not be diagnosed as a cycle, once the incorrect failure above is
432+
// fixed.
433+
fn F(A:! Z where .T = .V.U and .V = .Self and .U = ()) -> A.T {
434+
return ();
435+
}
436+
363437
// CHECK:STDOUT: --- fail_cycle.carbon
364438
// CHECK:STDOUT:
365439
// CHECK:STDOUT: constants {

toolchain/check/testdata/facet/nested_facet_types.carbon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ interface Z {
4343

4444
fn F(FF:! ((Z where .T = .U) where .T = .U) where .T = .U) {}
4545

46+
// --- fail_todo_nested_facet_types_same_two_associated.carbon
47+
library "[[@TEST_NAME]]";
48+
49+
interface Z {
50+
let T:! type;
51+
let U:! type;
52+
let V:! type;
53+
}
54+
55+
// TODO: There should not be a diagnostic here.
56+
//
57+
// CHECK:STDERR: fail_todo_nested_facet_types_same_two_associated.carbon:[[@LINE+4]]:12: error: associated constant `.(Z.T)` given two different values `.(Z.V)` and `.(Z.U)` [AssociatedConstantWithDifferentValues]
58+
// CHECK:STDERR: fn F(FF:! ((Z where .T = .U and .U = .V) where .T = .U and .U = .V) where .T = .U and .U = .V) {}
59+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
// CHECK:STDERR:
61+
fn F(FF:! ((Z where .T = .U and .U = .V) where .T = .U and .U = .V) where .T = .U and .U = .V) {}
62+
4663
// --- fail_nested_facet_types_different.carbon
4764
library "[[@TEST_NAME]]";
4865

@@ -174,6 +191,9 @@ interface Z { let X:! type; let Y:! type; }
174191
// Verify that the `.Y = ()` does not get applied to `.X = .Y` prematurely, as
175192
// that would lead to `.X = () and .X = .Y` when combined with the outer `where`
176193
// expression, which would be an error.
194+
//
195+
// TODO: There should be no diagnostic here.
196+
//
177197
// CHECK:STDERR: fail_todo_repeated_with_value_available.carbon:[[@LINE+4]]:10: error: associated constant `.(Z.X)` given two different values `()` and `.(Z.Y)` [AssociatedConstantWithDifferentValues]
178198
// CHECK:STDERR: fn F(T:! ((Z where .Y = ()) where .X = .Y) where .X = .Y) -> T.X {
179199
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)