This PR fixes an issue where uses of 'noncomputable' definitions can get incorrectly compiled, while also removing the use of 'noncomputable' definitions altogether. Some uses of 'noncomputable' definitions (e.g. Classical.propDecidable) do not get compiled correctly by type erasure. Running the optimizer on the result can lead to them being optimized away, eluding the later IR-level check for uses of noncomputable definitions. To fix this, we add a 'noncomputable' check earlier in the erase_irrelevant pass.
21 lines
518 B
Text
21 lines
518 B
Text
/-!
|
|
# Improve compiler IR check message for users when constants are not compiled
|
|
-/
|
|
|
|
/-
|
|
This is a simplified version of the example in #1785.
|
|
Note that the error changes if the typeclass argument is removed.
|
|
-/
|
|
|
|
noncomputable
|
|
def char (R : Type) [∀ n, OfNat R n] : Nat := 0
|
|
|
|
/--
|
|
error: failed to compile definition, consider marking it as 'noncomputable'
|
|
because it depends on 'char', which is 'noncomputable'
|
|
-/
|
|
#guard_msgs in
|
|
def bug (R : Type) [∀ n, OfNat R n] : R :=
|
|
match char R with
|
|
| 0 => 1
|
|
| _ => 0
|