fix(frontends/lean/decl_cmds): constants command

closes #445
This commit is contained in:
Leonardo de Moura 2015-02-24 16:27:13 -08:00
parent 42289d4334
commit 34c36648bb
2 changed files with 43 additions and 29 deletions

View file

@ -232,7 +232,7 @@ static environment variables_cmd_core(parser & p, variable_kind k) {
check_variable_kind(p, k);
auto pos = p.pos();
environment env = p.env();
while (true) {
optional<binder_info> bi = parse_binder_info(p, k);
buffer<name> ids;
while (!p.curr_is_token(get_colon_tk())) {
@ -259,9 +259,17 @@ static environment variables_cmd_core(parser & p, variable_kind k) {
new_ls = append(ls, new_ls);
env = declare_var(p, env, id, new_ls, new_type, k, bi, pos);
}
if (!p.curr_is_token(get_lparen_tk()) && !p.curr_is_token(get_lcurly_tk()) &&
!p.curr_is_token(get_ldcurly_tk()) && !p.curr_is_token(get_lbracket_tk()))
break;
if (p.curr_is_token(get_lparen_tk()) || p.curr_is_token(get_lcurly_tk()) ||
p.curr_is_token(get_ldcurly_tk()) || p.curr_is_token(get_lbracket_tk())) {
if (k == variable_kind::Constant || k == variable_kind::Axiom) {
// Hack: temporarily update the parser environment.
// We must do that to be able to process
// constants (A : Type) (a : A)
parser::local_scope scope2(p, env);
return variables_cmd_core(p, k);
} else {
return variables_cmd_core(p, k);
}
}
return env;
}

6
tests/lean/run/445.lean Normal file
View file

@ -0,0 +1,6 @@
constants (A : Type) (a : A)
constants (B : Type) (b₁ b₂ : B) (H : b₁ = b₂)
check a
check b₁
check H