feat(library/blast/forward/pattern): add minimal pattern validation
This commit is contained in:
parent
2090e9124c
commit
ec7c38d847
3 changed files with 11 additions and 0 deletions
|
@ -14,6 +14,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/abstract.h"
|
||||
#include "kernel/instantiate.h"
|
||||
#include "library/kernel_serializer.h"
|
||||
#include "library/generic_exception.h"
|
||||
#include "library/tmp_type_context.h"
|
||||
#include "library/annotation.h"
|
||||
#include "library/occurs.h"
|
||||
|
@ -137,6 +138,8 @@ bool has_pattern_hints(expr const & e) {
|
|||
expr mk_pattern_hint(expr const & e) {
|
||||
if (has_pattern_hints(e))
|
||||
throw exception("invalid pattern hint, nested patterns hints are not allowed");
|
||||
if (!is_app(e))
|
||||
throw_generic_exception("invalid pattern hint, pattern must be applications", e);
|
||||
return mk_annotation(*g_pattern_hint, e);
|
||||
}
|
||||
|
||||
|
|
7
tests/lean/bad_pattern.lean
Normal file
7
tests/lean/bad_pattern.lean
Normal file
|
@ -0,0 +1,7 @@
|
|||
constant P : nat → Prop
|
||||
|
||||
lemma tst₁ [forward] : ∀ x, (: P x :) := -- Fine
|
||||
sorry
|
||||
|
||||
lemma tst₂ [forward] : ∀ x, P (: x :) := -- Error
|
||||
sorry
|
1
tests/lean/bad_pattern.lean.expected.out
Normal file
1
tests/lean/bad_pattern.lean.expected.out
Normal file
|
@ -0,0 +1 @@
|
|||
bad_pattern.lean:6:33: error: invalid pattern hint, pattern must be applications
|
Loading…
Reference in a new issue