|
|
@@ -196,23 +196,34 @@ interface M { let X:! type; }
|
|
|
// CHECK:STDERR:
|
|
|
fn F(T:! M where .X = {} and .X = () and .X = {}) {}
|
|
|
|
|
|
-// --- todo_fail_cycle_single.carbon
|
|
|
+// --- fail_cycle_single.carbon
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
interface M { let X:! type; }
|
|
|
|
|
|
-// TODO: This should fail, as it resolves to `.X = .X` which is cyclical.
|
|
|
+// CHECK:STDERR: fail_cycle_single.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn F(T:! M where .X = .X) {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
fn F(T:! M where .X = .X) {}
|
|
|
|
|
|
-// --- todo_fail_cycle.carbon
|
|
|
+// --- fail_cycle.carbon
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
-interface M { let X:! type; let Y:! type; }
|
|
|
+interface M { let X:! type; let Y:! type; let Z:! type; }
|
|
|
|
|
|
-// TODO: This should fail, as it resolves to `.X = .X` which is cyclical.
|
|
|
-fn F(T:! M where .X = .Y and .Y = .X) {}
|
|
|
+// This fails because it resolves to `.X = .X` which is cyclical.
|
|
|
+// The value of .X and .Y becomes <error> but .Z is still valid.
|
|
|
+//
|
|
|
+//@dump-sem-ir-begin
|
|
|
+// CHECK:STDERR: fail_cycle.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn F(T:! M where .X = .Y and .Y = .X and .Z = ()) {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
+fn F(T:! M where .X = .Y and .Y = .X and .Z = ()) {}
|
|
|
+//@dump-sem-ir-end
|
|
|
|
|
|
-// --- todo_fail_cycle_between_interfaces.carbon
|
|
|
+// --- fail_cycle_between_interfaces.carbon
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
interface I {
|
|
|
@@ -223,10 +234,15 @@ interface J {
|
|
|
let X3:! type;
|
|
|
}
|
|
|
|
|
|
-// TODO: This should fail, as it resolves to `.X1 = .X1` which is cyclical.
|
|
|
+// This fails because it resolves to `.X1 = .X1` which is cyclical.
|
|
|
+//
|
|
|
+// CHECK:STDERR: fail_cycle_between_interfaces.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(I.X2)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn G(T:! I & J where .X1 = .X3 and .X2 = .X1 and .X3 = .X2) {}
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
fn G(T:! I & J where .X1 = .X3 and .X2 = .X1 and .X3 = .X2) {}
|
|
|
|
|
|
-// --- todo_fail_indirect_cycle.carbon
|
|
|
+// --- fail_indirect_cycle.carbon
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
interface I {
|
|
|
@@ -234,15 +250,24 @@ interface I {
|
|
|
let X2:! type;
|
|
|
}
|
|
|
|
|
|
-// TODO: This should fail, as it resolves to `.X1 = .X1**` which is cyclical.
|
|
|
+// This fails because it resolves to `.X1 = .X1**` which is cyclical.
|
|
|
+//
|
|
|
+// CHECK:STDERR: fail_indirect_cycle.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(I.X1)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn F(T:! I where .X1 = .X2* and .X2 = .X1*);
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
fn F(T:! I where .X1 = .X2* and .X2 = .X1*);
|
|
|
|
|
|
class C(T:! type);
|
|
|
-// TODO: This should fail, as it resolves to `.X1 = C(C(.X1))` which is
|
|
|
-// cyclical.
|
|
|
+// This fails because it resolves to `.X1 = C(C(.X1))` which is cyclical.
|
|
|
+//
|
|
|
+// CHECK:STDERR: fail_indirect_cycle.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(I.X1)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn G(T:! I where .X1 = C(.X2) and .X2 = C(.X1));
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
fn G(T:! I where .X1 = C(.X2) and .X2 = C(.X1));
|
|
|
|
|
|
-// --- todo_fail_complex_indirect_cycle.carbon
|
|
|
+// --- fail_complex_indirect_cycle.carbon
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
|
|
interface I {
|
|
|
@@ -253,8 +278,13 @@ interface I {
|
|
|
|
|
|
class C(T:! type, U:! type);
|
|
|
|
|
|
-// TODO: This should fail, as it resolves to `.X1 = C(C(.X3, .X1), .X3)` which
|
|
|
-// is cyclical.
|
|
|
+// This fails because it resolves to `.X1 = C(C(.X3, .X1), .X3)` which is
|
|
|
+// cyclical.
|
|
|
+//
|
|
|
+// CHECK:STDERR: fail_complex_indirect_cycle.carbon:[[@LINE+4]]:10: error: found cycle in facet type constraint for `.(I.X1)` [FacetTypeConstraintCycle]
|
|
|
+// CHECK:STDERR: fn F(T:! I where .X1 = C(.X2, .X3) and .X2 = C(.X3, .X1));
|
|
|
+// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+// CHECK:STDERR:
|
|
|
fn F(T:! I where .X1 = C(.X2, .X3) and .X2 = C(.X3, .X1));
|
|
|
|
|
|
// --- non-type.carbon
|
|
|
@@ -287,3 +317,88 @@ interface N {
|
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
// CHECK:STDERR:
|
|
|
fn F(T:! N where .Y = {.a = {}} and .Y = {.a = ()}) {}
|
|
|
+
|
|
|
+// CHECK:STDOUT: --- fail_cycle.carbon
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: constants {
|
|
|
+// CHECK:STDOUT: %M.type: type = facet_type <@M> [concrete]
|
|
|
+// CHECK:STDOUT: %M.assoc_type: type = assoc_entity_type @M [concrete]
|
|
|
+// CHECK:STDOUT: %assoc0: %M.assoc_type = assoc_entity element0, @M.%X [concrete]
|
|
|
+// CHECK:STDOUT: %assoc1: %M.assoc_type = assoc_entity element1, @M.%Y [concrete]
|
|
|
+// CHECK:STDOUT: %assoc2: %M.assoc_type = assoc_entity element2, @M.%Z [concrete]
|
|
|
+// CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic_self]
|
|
|
+// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
|
|
|
+// CHECK:STDOUT: %M.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @M [symbolic_self]
|
|
|
+// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %M.lookup_impl_witness, element0 [symbolic_self]
|
|
|
+// CHECK:STDOUT: %impl.elem1: type = impl_witness_access %M.lookup_impl_witness, element1 [symbolic_self]
|
|
|
+// CHECK:STDOUT: %impl.elem2: type = impl_witness_access %M.lookup_impl_witness, element2 [symbolic_self]
|
|
|
+// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
|
+// CHECK:STDOUT: %M_where.type: type = facet_type <@M where %impl.elem0 = <error> and %impl.elem1 = <error> and %impl.elem2 = %empty_tuple.type> [concrete]
|
|
|
+// CHECK:STDOUT: %T: %M_where.type = bind_symbolic_name T, 0 [symbolic]
|
|
|
+// CHECK:STDOUT: %pattern_type: type = pattern_type %M_where.type [concrete]
|
|
|
+// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
|
|
|
+// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: imports {
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: file {
|
|
|
+// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
|
|
|
+// CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
|
|
|
+// CHECK:STDOUT: } {
|
|
|
+// CHECK:STDOUT: %.loc13_12.1: type = splice_block %.loc13_12.2 [concrete = constants.%M_where.type] {
|
|
|
+// CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [concrete = constants.%M.type]
|
|
|
+// CHECK:STDOUT: <elided>
|
|
|
+// CHECK:STDOUT: %.Self.ref.loc13_18: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
|
|
|
+// CHECK:STDOUT: %X.ref.loc13_18: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
|
|
|
+// CHECK:STDOUT: %.Self.as_type.loc13_18: type = facet_access_type %.Self.ref.loc13_18 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %.loc13_18: type = converted %.Self.ref.loc13_18, %.Self.as_type.loc13_18 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %impl.elem0.loc13_18: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
|
|
|
+// CHECK:STDOUT: %.Self.ref.loc13_23: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
|
|
|
+// CHECK:STDOUT: %Y.ref.loc13_23: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
|
|
|
+// CHECK:STDOUT: %.Self.as_type.loc13_23: type = facet_access_type %.Self.ref.loc13_23 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %.loc13_23: type = converted %.Self.ref.loc13_23, %.Self.as_type.loc13_23 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %impl.elem1.loc13_23: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
|
|
|
+// CHECK:STDOUT: %.Self.ref.loc13_30: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
|
|
|
+// CHECK:STDOUT: %Y.ref.loc13_30: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
|
|
|
+// CHECK:STDOUT: %.Self.as_type.loc13_30: type = facet_access_type %.Self.ref.loc13_30 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %.loc13_30: type = converted %.Self.ref.loc13_30, %.Self.as_type.loc13_30 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %impl.elem1.loc13_30: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
|
|
|
+// CHECK:STDOUT: %.Self.ref.loc13_35: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
|
|
|
+// CHECK:STDOUT: %X.ref.loc13_35: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
|
|
|
+// CHECK:STDOUT: %.Self.as_type.loc13_35: type = facet_access_type %.Self.ref.loc13_35 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %.loc13_35: type = converted %.Self.ref.loc13_35, %.Self.as_type.loc13_35 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %impl.elem0.loc13_35: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
|
|
|
+// CHECK:STDOUT: %.Self.ref.loc13_42: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
|
|
|
+// CHECK:STDOUT: %Z.ref: %M.assoc_type = name_ref Z, @Z.%assoc2 [concrete = constants.%assoc2]
|
|
|
+// CHECK:STDOUT: %.Self.as_type.loc13_42: type = facet_access_type %.Self.ref.loc13_42 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %.loc13_42: type = converted %.Self.ref.loc13_42, %.Self.as_type.loc13_42 [symbolic_self = constants.%.Self.as_type]
|
|
|
+// CHECK:STDOUT: %impl.elem2: type = impl_witness_access constants.%M.lookup_impl_witness, element2 [symbolic_self = constants.%impl.elem2]
|
|
|
+// CHECK:STDOUT: %.loc13_48.1: %empty_tuple.type = tuple_literal ()
|
|
|
+// CHECK:STDOUT: %.loc13_48.2: type = converted %.loc13_48.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
|
|
|
+// CHECK:STDOUT: %.loc13_12.2: type = where_expr %.Self [concrete = constants.%M_where.type] {
|
|
|
+// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_18, %impl.elem1.loc13_23
|
|
|
+// CHECK:STDOUT: requirement_rewrite %impl.elem1.loc13_30, %impl.elem0.loc13_35
|
|
|
+// CHECK:STDOUT: requirement_rewrite %impl.elem2, %.loc13_48.2
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: %T.loc13_6.1: %M_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_6.2 (constants.%T)]
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: generic fn @F(%T.loc13_6.1: %M_where.type) {
|
|
|
+// CHECK:STDOUT: %T.loc13_6.2: %M_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_6.2 (constants.%T)]
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: !definition:
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: fn() {
|
|
|
+// CHECK:STDOUT: !entry:
|
|
|
+// CHECK:STDOUT: return
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|
|
|
+// CHECK:STDOUT: specific @F(constants.%T) {
|
|
|
+// CHECK:STDOUT: %T.loc13_6.2 => constants.%T
|
|
|
+// CHECK:STDOUT: }
|
|
|
+// CHECK:STDOUT:
|