-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
explorer/testdata/assoc_const/fail_equal_indirectly.carbon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// RUN: %{not} %{explorer} %s | %{FileCheck-strict} %s | ||
// RUN: %{not} %{explorer-trace} %s | %{FileCheck-allow-unmatched} %s | ||
// AUTOUPDATE: %{explorer} %s | ||
|
||
package ExplorerTest api; | ||
|
||
interface Iface { | ||
let T:! Type; | ||
} | ||
|
||
fn F[T:! Iface where .T == i32](x: T) {} | ||
|
||
class Class { | ||
impl as Iface where .T = i32 {} | ||
} | ||
|
||
// OK, constraint on `F` rewritten to `T:! Iface where U == i32`, which we can | ||
// prove from the constraint on `U`. | ||
fn G[U:! Type where .Self == i32, T:! Iface where .T = U](x: T, y: U) { | ||
F(x); | ||
} | ||
|
||
// Not OK: would require looking through two levels of `==`. | ||
fn H[U:! Type where .Self == i32, T:! Iface where .T == U](x: T, y: U) { | ||
// CHECK:STDERR: COMPILATION ERROR: {{.*}}//usr/local/google/home/richardsmith/carbon-lang/explorer/testdata/assoc_const/fail_equal_indirectly.carbon:[[@LINE+1]]: constraint requires that (T).(Iface.T) == i32, which is not known to be true | ||
F(x); | ||
} | ||
|
||
fn Main() -> i32 { | ||
var x: Class = {}; | ||
G(x, 0); | ||
H(x, 0); | ||
return 0; | ||
} |
35 changes: 35 additions & 0 deletions
35
explorer/testdata/assoc_const/fail_equal_to_dependent_type.carbon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// RUN: %{not} %{explorer} %s | %{FileCheck-strict} %s | ||
// RUN: %{not} %{explorer-trace} %s | %{FileCheck-allow-unmatched} %s | ||
// AUTOUPDATE: %{explorer} %s | ||
|
||
package ExplorerTest api; | ||
|
||
interface Iface { | ||
let T:! Type; | ||
} | ||
|
||
fn F[T:! Iface where .T == i32](x: T) {} | ||
|
||
fn G[T:! Iface where .T == i32](x: T) { | ||
F(x); | ||
} | ||
|
||
fn H[T:! Iface](x: T) { | ||
// CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_equal_to_dependent_type.carbon:[[@LINE+1]]: constraint requires that (T).(Iface.T) == i32, which is not known to be true | ||
F(x); | ||
} | ||
|
||
class Class { | ||
impl as Iface where .T = i32 {} | ||
} | ||
|
||
fn Main() -> i32 { | ||
var x: Class = {}; | ||
G(x); | ||
H(x); | ||
return 0; | ||
} |