fix(frontends/lean/parser): pass error-recovery flag from parser to elaborator

This commit is contained in:
Gabriel Ebner 2017-05-21 18:36:54 +02:00 committed by Leonardo de Moura
parent 77a2311f09
commit 183bf63e26
35 changed files with 109 additions and 7 deletions

View file

@ -551,7 +551,8 @@ static environment run_command_cmd(parser & p) {
tactic = mk_app(mk_constant(get_has_bind_and_then_name()), tactic, try_triv);
expr val = mk_typed_expr(mk_true(), mk_by(tactic));
bool check_unassigned = false;
elaborate(env, opts, "_run_command", mctx, local_context(), val, check_unassigned);
bool recover_from_errors = true;
elaborate(env, opts, "_run_command", mctx, local_context(), val, check_unassigned, recover_from_errors);
return env;
}

View file

@ -3660,8 +3660,7 @@ expr elaborator::finalize_theorem_proof(expr const & val, theorem_finalization_i
pair<expr, level_param_names>
elaborate(environment & env, options const & opts, name const & decl_name,
metavar_context & mctx, local_context const & lctx, expr const & e,
bool check_unassigned) {
bool recover_from_errors = false;
bool check_unassigned, bool recover_from_errors) {
elaborator elab(env, opts, decl_name, mctx, lctx, recover_from_errors);
expr r = elab.elaborate(e);
auto p = elab.finalize(r, check_unassigned, true);

View file

@ -335,7 +335,7 @@ public:
pair<expr, level_param_names> elaborate(environment & env, options const & opts, name const & decl_name,
metavar_context & mctx, local_context const & lctx,
expr const & e, bool check_unassigend);
expr const & e, bool check_unassigned, bool recover_from_errors);
/** \brief Translated local constants (and undefined constants) occurring in \c e into
local constants provided by \c ctx.

View file

@ -753,7 +753,7 @@ pair<expr, level_param_names> parser::elaborate(name const & decl_name,
expr const & e, bool check_unassigned) {
expr tmp_e = adapter.translate_to(e);
pair<expr, level_param_names> r =
::lean::elaborate(m_env, get_options(), decl_name, mctx, adapter.lctx(), tmp_e, check_unassigned);
::lean::elaborate(m_env, get_options(), decl_name, mctx, adapter.lctx(), tmp_e, check_unassigned, m_error_recovery);
expr new_e = r.first;
new_e = adapter.translate_from(new_e);
return mk_pair(new_e, r.second);

View file

@ -6,3 +6,20 @@ has type
source.Hom A B
but is expected to have type
source.Hom C ?m_1
1279.lean:12:55: error: type mismatch at application
target.compose (onMorphisms g) (onMorphisms f)
term
onMorphisms f
has type
target.Hom (onObjects A) (onObjects B)
but is expected to have type
target.Hom (onObjects C) (onObjects ?m_1)
1279.lean:12:33: error: don't know how to synthesize placeholder
context:
source target : Category,
onObjects : source.Obj → target.Obj,
onMorphisms : Π ⦃A B : source.Obj⦄, source.Hom A B → target.Hom (onObjects A) (onObjects B),
A B C : source.Obj,
f : source.Hom A B,
g : source.Hom B C
⊢ source.Obj

View file

@ -5,3 +5,4 @@ choice_expl.lean:15:7: error: ambiguous overload, possible interpretations
N1.pr a b
Additional information:
choice_expl.lean:15:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1

View file

@ -11,6 +11,7 @@ has type
real
but is expected to have type
int
⁇ : ?M_1
↑i + x : real
x + ↑n : real
coe1.lean:35:9: error: type mismatch at application
@ -21,6 +22,7 @@ has type
real
but is expected to have type
⁇ : ?M_1
↑n + x : real
↑i + x : real
↑n + x : real

View file

@ -11,6 +11,7 @@ has type
real
but is expected to have type
int
⁇ : ?M_1
i + x : real
x + n : real
coe2.lean:37:9: error: type mismatch at application
@ -21,4 +22,5 @@ has type
real
but is expected to have type
⁇ : ?M_1
n + x : real

View file

@ -7,6 +7,7 @@ has type
but is expected to have type
A
⁇ : ?M_1
g : A → A
def4.lean:17:9: error: type mismatch at application
g 0
@ -16,6 +17,7 @@ has type
but is expected to have type
A
⁇ : ?M_1
f : Π (A : Type u_1), A → A
f 0 :
g 0 :

View file

@ -3,4 +3,6 @@
elab1.lean:13:7: error: invalid '@', function is overloaded, use fully qualified names (overloads: boo.subst, foo.subst)
elab1.lean:15:7: error: invalid '@@', function is overloaded, use fully qualified names (overloads: boo.subst, foo.subst)
elab1.lean:19:7: error: invalid overloaded application, elaborator has special support for 'eq.subst' (it is handled as an "eliminator"), but this kind of constant cannot be overloaded (solution: use fully qualified names) (overloads: eq.subst, boo.subst, foo.subst)
⁇ : ?M_1
elab1.lean:25:7: error: invalid 'eq.subst' application, elaborator has special support for this kind of application (it is handled as an "eliminator"), but the expected type must be known
⁇ : ?M_1

View file

@ -3,6 +3,7 @@ elab11.lean:6:7: error: ambiguous overload, possible interpretations
boo.f 1
Additional information:
elab11.lean:6:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
bla.f 1 :
boo.f 1 : bool
elab11.lean:16:8: error: none of the overloads are applicable
@ -41,3 +42,4 @@ has type
bool
but is expected to have type
string
⁇ : string

View file

@ -1,16 +1,31 @@
elab12.lean:1:31: error: type expected at
0
elab12.lean:1:39: error: function expected at
rfl
Additional information:
elab12.lean:1:39: context: switched to simple application elaboration procedure because failed to use expected type to elaborate it, error message
too many arguments
elab12.lean:2:2: error: function expected at
H
λ (a : ), have H : ⁇, from ⁇, ⁇ : ∀ (a : ), a = a
elab12.lean:4:43: error: function expected at
rfl
Additional information:
elab12.lean:4:43: context: switched to simple application elaboration procedure because failed to use expected type to elaborate it, error message
too many arguments
elab12.lean:5:2: error: function expected at
H
λ (a : ), have H : a = a, from ⁇, ⁇ : ∀ (a : ), a = a
elab12.lean:7:45: error: invalid have-expression, expression
a + 0
has type
but is expected to have type
a = a
elab12.lean:8:2: error: function expected at
H
λ (a : ), have H : a = a, from ⁇, ⁇ : ∀ (a : ), a = a
elab12.lean:11:2: error: function expected at
H
λ (a : ), have H : a = a, from rfl, ⁇ : ∀ (a : ), a = a
λ (a : ), have H : a = a, from rfl, H : ∀ (a : ), a = a

View file

@ -7,4 +7,5 @@ has type
bool
but is expected to have type
nat
⁇ : ?M_1
@bla.{0 0} nat bool (@has_zero.zero.{0} nat nat.has_zero) (@has_zero.zero.{0} nat nat.has_zero) bool.tt : nat

View file

@ -13,11 +13,13 @@ function expected at
boo.f 0 1 2
Additional information:
elab4.lean:13:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
elab4.lean:15:7: error: ambiguous overload, possible interpretations
foo.f 0 1
boo.f 0 1
Additional information:
elab4.lean:15:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
foo.f bool.tt 2 : bool
bla.f bool.tt bool.ff bool.tt : bool → bool
elab4.lean:21:7: error: ambiguous overload, possible interpretations
@ -25,4 +27,5 @@ elab4.lean:21:7: error: ambiguous overload, possible interpretations
foo.f bool.tt bool.ff
Additional information:
elab4.lean:21:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
foo.f 0 1 :

View file

@ -12,13 +12,16 @@ function expected at
f 0 1 2
Additional information:
elab4b.lean:9:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
elab4b.lean:11:7: error: ambiguous overload, possible interpretations
foo.f 0 1
boo.f 0 1
Additional information:
elab4b.lean:11:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
elab4b.lean:13:7: error: ambiguous overload, possible interpretations
bla.f bool.tt bool.ff
foo.f bool.tt bool.ff
Additional information:
elab4b.lean:13:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1

View file

@ -39,3 +39,4 @@ nat.succ (nat.succ (nat.succ (nat.succ ⁇)))
2
elab_error_recovery.lean:21:13: error: type expected at
0
∀ (x : ⁇), x = x : Prop

View file

@ -1,5 +1,8 @@
error_full_names.lean:4:7: error: failed to synthesize type class instance for
⊢ has_zero nat
error_full_names.lean:4:9: error: failed to synthesize type class instance for
⊢ has_add nat
0 + nat.zero : nat
error_full_names.lean:8:7: error: type mismatch at application
nat.succ nat.zero
term
@ -8,3 +11,4 @@ has type
nat
but is expected to have type
⁇ : ?M_1

View file

@ -5,10 +5,13 @@ error_pos.lean:4:43: error: type expected at
B
error_pos.lean:9:40: error: type expected at
B
λ (A : Type) (B : A → Type) (b : ⁇), true : Π (A : Type), (A → Type) → ⁇ → Prop
error_pos.lean:11:36: error: type expected at
B
λ (A : Type) (B : A → Type), ⁇ → true : Π (A : Type), (A → Type) → Prop
error_pos.lean:13:43: error: type expected at
B
λ (A : Type) (B : A → Type) (b : ⁇), b : Π (A : Type), (A → Type) → ⁇ → ⁇
error_pos.lean:15:105: error: invalid let-expression, expression
a₁
has type

View file

@ -3,10 +3,12 @@ field_access.lean:5:8: error: invalid projection, structure expected
l
has type
list
⁇ : ?M_1
field_access.lean:7:13: error: invalid projection, structure has only 2 field(s)
(1, 2)
which has type
?m_1 × ?m_2
⁇ : ?M_1
field_access.lean:10:1: error: invalid field notation, 'forr' is not a valid "field" because environment does not contain 'list.forr'
l
which has type

View file

@ -2,3 +2,4 @@ inst_error.lean:1:39: error: failed to synthesize type class instance for
A : Type,
a b c : A
⊢ decidable (a = b ∧ a = c)
λ (A : Type) (a b c : A), ite (a = b ∧ a = c) tt ff : Π (A : Type), A → A → A → bool

View file

@ -1,3 +1,4 @@
instance_cache_bug1.lean:5:9: error: failed to synthesize type class instance for
⊢ has_add A
a + a : A
a + a : A

View file

@ -1,7 +1,8 @@
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"},{"caption":"","file_name":"f","pos_col":27,"pos_line":7,"severity":"error","text":"invalid expression, `)` expected"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"},{"caption":"","file_name":"f","pos_col":27,"pos_line":7,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"check result","file_name":"f","pos_col":0,"pos_line":6,"severity":"information","text":"λ (tac : tactic unit), (abstract tac none) : tactic unit → tactic unit"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"},{"caption":"check result","file_name":"f","pos_col":0,"pos_line":3,"severity":"information","text":"⁇ : ?M_1"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"},{"caption":"check result","file_name":"f","pos_col":0,"pos_line":3,"severity":"information","text":"⁇ : ?M_1"},{"caption":"","file_name":"f","pos_col":27,"pos_line":7,"severity":"error","text":"invalid expression, `)` expected"}],"response":"all_messages"}
{"msgs":[{"caption":"","file_name":"f","pos_col":0,"pos_line":6,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"","file_name":"f","pos_col":8,"pos_line":3,"severity":"error","text":"ambiguous overload, possible interpretations\n trace\n tactic.trace\nAdditional information:\nf:3:8: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available"},{"caption":"check result","file_name":"f","pos_col":0,"pos_line":3,"severity":"information","text":"⁇ : ?M_1"},{"caption":"","file_name":"f","pos_col":27,"pos_line":7,"severity":"error","text":"invalid expression, `)` expected"},{"caption":"check result","file_name":"f","pos_col":0,"pos_line":6,"severity":"information","text":"λ (tac : tactic unit), (abstract tac none) : tactic unit → tactic unit"}],"response":"all_messages"}
{"message":"file invalidated","response":"ok","seq_num":0}
{"response":"ok","seq_num":4}
{"record":{"full-id":"tactic.abstract","source":,"type":"tactic unit → opt_param (option name) none → opt_param bool tt → tactic unit"},"response":"ok","seq_num":7}

View file

@ -12,3 +12,10 @@ has type
Π (p q : bool), p → q → Π (c : bool), (p → q → c) → c
but is expected to have type
Π (p q : bool), p → q → and q p
let bool : Type := Prop,
and : bool → bool → Prop := λ (p q : bool), Π (c : bool), (p → q → c) → c,
and_intro : Π (p q : bool), p → q → and q p := ⁇,
and_elim_left : Π (p q : bool), and p q → p := λ (p q : bool) (H : and p q), H p (λ (H1 : p) (H2 : q), H1),
and_elim_right : Π (p q : bool), and p q → q := λ (p q : bool) (H : and p q), H q (λ (H1 : p) (H2 : q), H2)
in and_intro :
∀ (p q : Prop), p → q → (λ (p q : Prop), ∀ (c : Prop), (p → q → c) → c) q p

View file

@ -6,3 +6,4 @@ has type
num
but is expected to have type
⁇ : ?M_1

View file

@ -3,6 +3,7 @@ nary_overload.lean:16:7: error: ambiguous overload, possible interpretations
[a, b, c]
Additional information:
nary_overload.lean:16:7: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
[a, b, c] : vec A
[a, b, c] : lst A
@vec.cons A a (@vec.cons A b (@vec.cons A c (@vec.nil A))) : vec.{0} A

View file

@ -7,3 +7,4 @@ has type
bool
but is expected to have type
Prop
⁇ : ?M_1

View file

@ -1,9 +1,19 @@
notation_error_pos.lean:6:7: error: failed to synthesize type class instance for
⊢ has_one string
notation_error_pos.lean:6:7: error: failed to synthesize type class instance for
⊢ has_add string
"a" + 1 : string
notation_error_pos.lean:8:7: error: failed to synthesize type class instance for
⊢ has_one string
notation_error_pos.lean:8:7: error: failed to synthesize type class instance for
⊢ has_add string
"a" + 1 : string
notation_error_pos.lean:10:7: error: failed to synthesize type class instance for
⊢ has_one string
notation_error_pos.lean:10:7: error: failed to synthesize type class instance for
⊢ has_add string
1 + "a" : string
notation_error_pos.lean:12:7: error: failed to synthesize type class instance for
x : string
⊢ has_add string
λ (x : string), x + "b" : string → string

View file

@ -1,5 +1,11 @@
o : N
z : N
eq a gz : Prop
num2.lean:24:8: error: failed to synthesize type class instance for
⊢ has_zero G
num2.lean:24:8: error: invalid type ascription, expression has type
N
but is expected to have type
G
eq gz a : Prop
eq b z : Prop

View file

@ -1,3 +1,7 @@
@eq N a z : Prop
num3.lean:14:12: error: invalid type ascription, expression has type
N
but is expected to have type
num
@eq num 2 1 : Prop
@eq num 2 1 : Prop

View file

@ -22,5 +22,6 @@ but is expected to have type
nat
Additional information:
over_notation.lean:11:10: context: switched to basic overload resolution where arguments are elaborated without any information about the expected type because expected type was not available
⁇ : ?M_1
f 1 (f 2 (f 3 0)) : nat
g "a" (g "b" (g "c" "")) : string

View file

@ -26,4 +26,5 @@ private_structure.lean:30:7: error: unknown identifier 'point.y'
def foo.bla : Type :=
point
private_structure.lean:35:8: error: invalid constructor ⟨...⟩, type is a private inductive datatype
⁇ : foo.bla
foo.mk : foo.bla

View file

@ -9,15 +9,18 @@ proj_notation.lean:29:19: error: invalid field notation, 'fst' is not a valid "f
c
which has type
car
λ (c : car), ⁇ : car → ?M_1
proj_notation.lean:31:21: error: invalid projection, index must be greater than 0
proj_notation.lean:33:19: error: invalid projection, structure has only 2 field(s)
c
which has type
car
λ (c : car), ⁇ : car → ?M_1
proj_notation.lean:35:19: error: invalid projection, structure expected
n
has type
λ (n : ), ⁇ : → ?M_1
p.fst :
p.snd :
λ (c : car), (c.pos).y : car →

View file

@ -6,3 +6,4 @@ has type
string
but is expected to have type
caching_user_attribute string
⁇ : ?M_1

View file

@ -7,6 +7,7 @@ has type
B
but is expected to have type
N
⁇ : ?M_1
[x, y, z, x, y, y] : list
[x] : list
[] : list

View file

@ -1,3 +1,5 @@
λ (f g : N → N → N) (x y : N), f x (g x y) : (N → N → N) → (N → N → N) → N → N → N
t12.lean:7:7: error: function expected at
a
⁇ : ?M_1
t12.lean:7:8: error: command expected