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
+4 -3
View File
@@ -10,9 +10,10 @@
package ExplorerTest api;
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/fail_invalid_fnty.carbon:[[@LINE+3]]: type error in negation
// CHECK: expected: i32
// CHECK: actual: Bool
// TODO: We should type-check the prelude before the main input so that we can
// use it within the types of top-level declarations.
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/fail_invalid_fnty.carbon:[[@LINE+2]]: type error in `-`:
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/fail_invalid_fnty.carbon:[[@LINE+1]]: missing declaration for builtin `Negate`
fn f(g: __Fn(-true) -> true) {
}