fix(frontends/lean/decl_cmds): do not allow section parameters/variables to shadow existing parameters/variables
This commit is contained in:
parent
a52b21c92d
commit
6950b4aa9b
3 changed files with 14 additions and 0 deletions
|
@ -85,6 +85,8 @@ static environment declare_var(parser & p, environment env,
|
|||
lean_assert(k == variable_kind::Parameter || k == variable_kind::Variable);
|
||||
if (k == variable_kind::Parameter)
|
||||
check_parameter_type(p, n, type, pos);
|
||||
if (p.get_local(n))
|
||||
throw parser_error(sstream() << "invalid declaration, section/context already contains '" << n << "'", pos);
|
||||
name u = p.mk_fresh_name();
|
||||
expr l = p.save_pos(mk_local(u, n, type, bi), pos);
|
||||
p.add_local_expr(n, l, k == variable_kind::Variable);
|
||||
|
|
11
tests/lean/sec.lean
Normal file
11
tests/lean/sec.lean
Normal file
|
@ -0,0 +1,11 @@
|
|||
import data.prod
|
||||
open prod
|
||||
|
||||
section
|
||||
variable A : Type
|
||||
variable a : A
|
||||
variable A : Type
|
||||
variable b : A
|
||||
|
||||
definition foo := a
|
||||
end
|
1
tests/lean/sec.lean.expected.out
Normal file
1
tests/lean/sec.lean.expected.out
Normal file
|
@ -0,0 +1 @@
|
|||
sec.lean:7:11: error: invalid declaration, section/context already contains 'A'
|
Loading…
Reference in a new issue