Skip to content

Commit b63fa6e

Browse files
committed
adjust-nesting
1 parent fd9072a commit b63fa6e

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

toolchain/check/testdata/facet/period_self.carbon

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ interface I(T:! type) {
243243
fn G() -> T;
244244
}
245245

246-
// The first `.Self` refers to `T`. The second `.Self` is not attached to a
247-
// facet value until later.
248-
fn F(T:! I(.Self) where .A = ((I(.Self) where .B = {}) where .A = {})) {
246+
// Both `.Self` refer to `T`. The first because it's the interface for the
247+
// binding. The second because it refers to the top level facet type which is
248+
// constraining the binding.
249+
fn F(T:! I(.Self) where .A = ((I(.Self) where .B = {}) where .A = {}) and .B = {}, U:! T.A) {
249250
// T.G() has type T.
250251
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+7]]:14: error: cannot implicitly convert expression of type `.Self` to `T` [ConversionFailure]
251252
// CHECK:STDERR: let t: T = T.G();
@@ -255,31 +256,41 @@ fn F(T:! I(.Self) where .A = ((I(.Self) where .B = {}) where .A = {})) {
255256
// CHECK:STDERR: ^~~~~
256257
// CHECK:STDERR:
257258
let t: T = T.G();
258-
// The second `.Self` now refers to `U`.
259-
fn F2(U:! T.A) {
260-
// U.G() has type U.
261-
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+7]]:16: error: cannot implicitly convert expression of type `.Self` to `U` [ConversionFailure]
262-
// CHECK:STDERR: let u: U = U.G();
263-
// CHECK:STDERR: ^~~~~
264-
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:16: note: type `.Self` does not implement interface `Core.ImplicitAs(U)` [MissingImplInMemberAccessNote]
265-
// CHECK:STDERR: let u: U = U.G();
266-
// CHECK:STDERR: ^~~~~
267-
// CHECK:STDERR:
268-
let u: U = U.G();
269-
270-
fn F3(V:! I(T) where .A = (I(U) where .A ={} and .B = {})) {
271-
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+7]]:7: error: cannot convert type `V` that implements `I(T) where .(I(T).A) = I(U) where .(I(U).A) = {} and .(I(U).B) = {}` into type implementing `I(.Self) where .(I(.Self).A) = I(.Self) where .(I(.Self).B) = {} and .(I(.Self).A) = {}` [ConversionFailureFacetToFacet]
272-
// CHECK:STDERR: F(V);
273-
// CHECK:STDERR: ^~~~
274-
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE-26]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
275-
// CHECK:STDERR: fn F(T:! I(.Self) where .A = ((I(.Self) where .B = {}) where .A = {})) {
276-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277-
// CHECK:STDERR:
278-
F(V);
279-
}
280-
}
259+
// U.G() has type T.
260+
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+7]]:14: error: cannot implicitly convert expression of type `.Self` to `T` [ConversionFailure]
261+
// CHECK:STDERR: let u: T = U.G();
262+
// CHECK:STDERR: ^~~~~
263+
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:14: note: type `.Self` does not implement interface `Core.ImplicitAs(T)` [MissingImplInMemberAccessNote]
264+
// CHECK:STDERR: let u: T = U.G();
265+
// CHECK:STDERR: ^~~~~
266+
// CHECK:STDERR:
267+
let u: T = U.G();
268+
269+
// Shows both `I(.Self)` are `I(T)`.
270+
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:9: error: found cycle in facet type constraint for `.(I(T).A)` [FacetTypeConstraintCycle]
271+
// CHECK:STDERR: T as (I(T) where .A = (I(T) where .A = {} and .B = {}));
272+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273+
// CHECK:STDERR:
274+
T as (I(T) where .A = (I(T) where .A = {} and .B = {}));
275+
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:3: error: cannot convert type `U` that implements `I(.Self) where .(I(.Self).B) = {} and .(I(.Self).A) = {}` into type implementing `I(T) where .(I(T).A) = {} and .(I(T).B) = {}` [ConversionFailureFacetToFacet]
276+
// CHECK:STDERR: U as (I(T) where .A ={} and .B = {});
277+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278+
// CHECK:STDERR:
279+
U as (I(T) where .A ={} and .B = {});
281280
}
282281

282+
// --- todo_fail_nested_period_self_ambiguous.carbon
283+
library "[[@TEST_NAME]]";
284+
285+
interface I(T:! type) {
286+
let A:! type;
287+
}
288+
289+
// TODO: This should be an error: The third `.Self` becomes undefined. It's not
290+
// referring to `T` but we need each explicit `.Self` to be replaced with
291+
// something at the end of the expression.
292+
fn F(T:! I(.Self) where .A = (I(.Self) where .A = I(.Self))) {}
293+
283294
// CHECK:STDOUT: --- period_self_param.carbon
284295
// CHECK:STDOUT:
285296
// CHECK:STDOUT: constants {

0 commit comments

Comments
 (0)