lean4-htt/tests/compiler
Leonardo de Moura 2120883307 refactor: heterogeneous operators
@Kha I had some unexpected surprises, but it is a good change.
Here is the summary.

1- We could get rid of `a %ₙ b` and `ModN` class. We can use `HMod`
instead. It was a positive surprise since I didn't remember we had
this `ModN` class.

2- Coercions are never used in heterogeneous operators. This is
expected since `a * b` is now notation for `HMul.hMul a b`, and
`a` and `b` may have different types. I manually added instances such
as `HMul Nat Int Int`. However, I did not try to add generic instances
such as
```
instance [Coe a b] [Mul b] : HMul a b b where
  hMul x y := mul (coe x) y
```
I will try later.

3- Give `h : cs.size > 0`, I got a type error at
```
let idx : Fin cs.size := ⟨cs.size - 1, Nat.predLt h⟩
```
`Nat.predLt h` has type `Nat.pred cs.size < cs.size`
However, `Nat.pred cs.size` doesn't unify with `cs.size - 1`.
The problem is that we can't synthesize the `HSub` instance until
we apply the default instances.
It worked before because `isDefEq` would force the pending TC
problem `Sub Nat` to be resolved, and after that we would be able
to reduce `cs.size - 1` and establish that it is definitionally
equal to `Nat.pred cs.size`.
I considered two possible workarounds
a) `let idx : Fin cs.size := ⟨cs.size - (1:Nat), Nat.predLt h⟩`
b) `let idx : Fin cs.size := ⟨cs.size - 1, by exact Nat.predLt h⟩`
The first one works because we are not providing enough information
for synthesizing the `HSub` instance. The second works because it
postpones the elaboration of `Nat.predLt h`. The default instances
will be applied before we start applying tactics.

4- The `.` notation is affected too. For example, `(x + 1).toUInt8`
doesn't work since we don't know the type of `x+1` until we apply
default instances. I fixed it by using `(x + (1:Nat)).toUInt8`.
Another possible fix is `Nat.toUInt8 (x + 1)`.
Similarly, `(x+1).fold ...` doesn't work.

5- The following code failed to be elaborated
```
indent (push s!"{ss'}\n") (some (0 - Format.getIndent (← getOptions)))
```
It was working before, but it relied on how the expected type is
propagated. The elaborator process
```
some (0 - Format.getIndent (← getOptions))
```
with expected type `(Option Int)`. So, the `-` is interpreted as
`Int.sub` although `Format.getIndent (← getOptions)` has type `Nat`.
In the new `HSub`, the expected type doesn't really influence TC
resolution since it is an `outparam`. So, we failed with the error
failed to synthesize `HSub Nat Nat Int`.
One possible fix was to add the instance `HSub Nat Nat Int` with
`Int.sub`, but I used the following fix
```
some ((0 : Int) - Format.getIndent (← getOptions))
```
which makes it clear that we want the `Int.sub` operator instead of
`Nat.sub`.
2020-12-01 14:02:46 -08:00
..
foreign chore: fix tests 2020-11-25 09:25:45 -08:00
.gitignore feat: stop compiling Lean code as C++, remove --cpp option 2020-05-14 14:45:33 +02:00
append.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
append.lean.expected.out
array_test.lean refactor: use Lists for Array reference implementation 2020-11-17 17:05:53 -08:00
array_test.lean.expected.out feat: add Subarray 2020-10-09 16:06:24 -07:00
array_test2.lean chore: move tests to new frontend 2020-10-23 16:18:52 -07:00
array_test2.lean.expected.out
binomial.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
binomial.lean.expected.out chore(tests/compiler/binomial): further reduce input size for debug build of interpreter... 2019-09-12 18:26:15 +02:00
bytearray_bug.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
bytearray_bug.lean.expected.out fix(library/compiler): ByteArray bug 2019-06-03 15:01:16 -07:00
closure_bug1.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug1.lean.expected.out fix(library/init/lean/compiler/ir/emitcpp): header of big boxed functions 2019-07-08 21:52:01 -07:00
closure_bug2.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug2.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug3.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug3.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug4.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug4.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug5.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug5.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug6.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug6.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug7.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug7.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
closure_bug8.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
closure_bug8.lean.expected.out test: news tests 2019-12-19 05:51:04 -08:00
expr.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
expr.lean.expected.out chore: fix tests 2019-11-18 19:54:05 -08:00
float.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
float.lean.expected.out test: add test that exposed unboxing issue 2020-04-03 18:24:48 -07:00
float_cases_bug.lean chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
float_cases_bug.lean.expected.out fix(library/compiler/csimp): bug at float_cases_on 2019-08-05 13:23:27 -07:00
init.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
init.lean.expected.out feat: expand initialize macro 2020-10-10 08:23:49 -07:00
init.lean.no_interpreter feat: expand initialize macro 2020-10-10 08:23:49 -07:00
lazylist.lean chore: fix tests 2020-11-25 09:25:45 -08:00
lazylist.lean.expected.out
lazylist.lean.no_interpreter chore(tests/compiler): ignore some tests for the interpreter 2019-09-12 18:26:15 +02:00
map_big.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
map_big.lean.expected.out
map_big.lean.no_interpreter chore(tests/compiler): ignore some tests for the interpreter 2019-09-12 18:26:15 +02:00
partial.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
partial.lean.expected.out
phashmap.lean chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
phashmap.lean.expected.out test: speed up some tests for the debug interpreter 2019-12-07 21:51:59 +01:00
phashmap2.lean chore: fix tests 2020-10-20 16:15:30 -07:00
phashmap2.lean.expected.out test(tests/compiler): PersistentHashMap tests 2019-08-02 14:23:13 -07:00
phashmap3.lean chore: fix tests 2020-10-20 16:15:30 -07:00
phashmap3.lean.expected.out test(tests/compiler): PersistentHashMap tests 2019-08-02 14:23:13 -07:00
print_error.lean chore: move tests to new frontend 2020-10-23 14:07:26 -07:00
print_error.lean.expected.out chore: remove test special case 2020-05-04 11:11:11 +02:00
print_error.lean.expected.ret chore: remove test special case 2020-05-04 11:11:11 +02:00
qsortBadLt.lean chore: fix tests 2020-10-25 09:11:13 -07:00
qsortBadLt.lean.expected.out chore: fix tests 2019-10-07 15:57:02 -07:00
rbmap_library.lean refactor: heterogeneous operators 2020-12-01 14:02:46 -08:00
rbmap_library.lean.expected.out test: speed up some tests for the debug interpreter 2019-12-07 21:51:59 +01:00
reusebug.lean chore: avoid Has prefix in type classes 2020-10-27 18:29:19 -07:00
reusebug.lean.expected.out
StackOverflow.lean chore: fix tests 2020-10-25 09:11:13 -07:00
StackOverflow.lean.expected.out feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
StackOverflow.lean.expected.ret feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
StackOverflow.lean.no_interpreter feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
StackOverflowTask.lean chore: fix tests 2020-10-25 09:11:13 -07:00
StackOverflowTask.lean.expected.out feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
StackOverflowTask.lean.expected.ret feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
StackOverflowTask.lean.no_interpreter feat: detect stack overflows on all platforms and threads 2020-05-04 11:11:11 +02:00
str.lean chore: move tests to new frontend 2020-10-23 14:07:26 -07:00
str.lean.expected.out feat(library/init/data/string): add String.isPrefixOf 2019-06-06 14:20:50 -07:00
strictAndOr.lean chore: move tests to new frontend 2020-10-23 16:18:52 -07:00
strictAndOr.lean.expected.out
strictOrSimp.lean chore: fix tests 2020-10-24 16:46:21 -07:00
strictOrSimp.lean.expected.out
t1.lean chore: move tests to new frontend 2020-10-23 16:18:52 -07:00
t1.lean.expected.out
t2.lean chore: avoid Has prefix in type classes 2020-10-27 18:29:19 -07:00
t2.lean.expected.out test: do not ignore whitespace in diff 2020-08-06 09:26:48 -07:00
t4.lean chore: avoid Has prefix in type classes 2020-10-27 18:29:19 -07:00
t4.lean.expected.out
test_single.sh chore: factor out and unify common test behavior; retrieve lean from PATH 2020-05-14 14:38:52 +02:00
test_single_interpret.sh chore: factor out and unify common test behavior; retrieve lean from PATH 2020-05-14 14:38:52 +02:00
thunk.lean chore: move tests to new frontend 2020-10-23 14:07:26 -07:00
thunk.lean.expected.out
uint_fold.lean chore: move tests to new frontend 2020-10-23 14:07:26 -07:00
uint_fold.lean.expected.out