fix: missing check at infer_proj
We should not allow `h.1` if `h` is a proposition and the result is not. The recursor for `h`'s type can only eliminate into `Prop`.
This commit is contained in:
parent
622995b2c7
commit
db38bc4043
3 changed files with 11 additions and 1 deletions
|
|
@ -262,7 +262,10 @@ expr type_checker::infer_proj(expr const & e, bool infer_only) {
|
|||
}
|
||||
r = whnf(r);
|
||||
if (!is_pi(r)) throw invalid_proj_exception(env(), m_lctx, e);
|
||||
return binding_domain(r);
|
||||
r = binding_domain(r);
|
||||
if (is_prop(type) && !is_prop(r))
|
||||
throw invalid_proj_exception(env(), m_lctx, e);
|
||||
return r;
|
||||
}
|
||||
|
||||
/** \brief Return type of expression \c e, if \c infer_only is false, then it also check whether \c e is type correct or not.
|
||||
|
|
|
|||
3
tests/lean/unsound.lean
Normal file
3
tests/lean/unsound.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def foo (h : ∃ x: Nat, True) := h.1
|
||||
theorem contradiction : False :=
|
||||
(by decide : 0 ≠ 1) (show foo ⟨0, trivial⟩ = foo ⟨1, trivial⟩ from rfl)
|
||||
4
tests/lean/unsound.lean.expected.out
Normal file
4
tests/lean/unsound.lean.expected.out
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
unsound.lean:1:4-1:7: error: (kernel) invalid projection
|
||||
h.1
|
||||
unsound.lean:3:28-3:31: error: unknown identifier 'foo'
|
||||
unsound.lean:3:47-3:50: error: unknown identifier 'foo'
|
||||
Loading…
Add table
Reference in a new issue