blob: edbd0cc1004e508c939b0848e71af6463410ddec [file] [edit]
noncomputable def badPair : Nat × (Nat × Nat) := ⟨1, ⟨2, 3⟩⟩
noncomputable def badFun (a : Nat) : Nat := a
structure S (n : Nat)
structure T where
n : Nat
def test1 : S badPair.2.1 := {}
/--
error: failed to compile definition, consider marking it as 'noncomputable' because it depends on 'badPair', which is 'noncomputable'
-/
#guard_msgs in
def test2 : T := { n := badPair.2.1 }
def test3 (a : Nat) : S (badFun a) := {}
def test4 (a : Nat) : S ((badFun a) + 1) := {}
/--
error: failed to compile definition, consider marking it as 'noncomputable' because it depends on 'badFun', which is 'noncomputable'
-/
#guard_msgs in
def test5 (a : Nat) : T := { n := badFun a }
/--
error: failed to compile definition, consider marking it as 'noncomputable' because it depends on 'badFun', which is 'noncomputable'
-/
#guard_msgs in
def test6 (a : Nat) : T := { n := 2 * (badFun a) }
structure U (a : Nat × Nat)
structure V where
a : Nat × Nat
def test7 (a : Nat) : U (⟨badFun a, 0⟩) := {}
def test8 (a : Nat) : U ((V.mk ⟨badFun a, 1⟩).a) := {}
/--
error: failed to compile definition, consider marking it as 'noncomputable' because it depends on 'badFun', which is 'noncomputable'
-/
#guard_msgs in
def test9 (a : Nat) : V := ⟨a, badFun a⟩
-- `Erased.mk` is `macro_inline`, so its argument erases and `.out` inside it compiles.
structure Foo where
spec : Erased Nat
data : Nat
def test10 : Foo where
spec := Erased.mk (Erased.mk 0).out
data := 0
/--
error: failed to compile definition: it depends on 'Erased.out', which recovers the value of an erased variable. An erased variable's value is available in specifications such as `invariant` clauses and `assert`s, but not in compiled code. Consider marking the definition as 'noncomputable'.
-/
#guard_msgs in
def test11 : Foo where
spec := Erased.mk 0
data := (Erased.mk 0).out