Add extensibility support for arithmetic operators. (#1751)

Add new prelude interfaces `Negate`, `AddWith`, `SubWith`, and `MulWith`, and
use them to implement non-builtin arithmetic operations.
This commit is contained in:
Richard Smith
2022-07-27 15:09:27 -07:00
committed by GitHub
parent 34a18b5e9e
commit 15ec5113aa
20 changed files with 401 additions and 57 deletions
+2 -3
View File
@@ -11,9 +11,8 @@
package ExplorerTest api;
fn id[T:! Type](x: T) -> T {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_not_addable.carbon:[[@LINE+3]]: type error in addition(1)
// CHECK: expected: i32
// CHECK: actual: T:! Type
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_not_addable.carbon:[[@LINE+2]]: type error in `+`:
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_not_addable.carbon:[[@LINE+1]]: could not find implementation of interface AddWith(U = i32) for T:! Type
return x + 0;
}