feat(frontends/lean): add declaration to namespace without opening it, closes #161
This commit is contained in:
parent
e856a268a2
commit
570879b55f
4 changed files with 30 additions and 6 deletions
|
@ -33,7 +33,6 @@ static name g_coercion("[coercion]");
|
||||||
|
|
||||||
environment universe_cmd(parser & p) {
|
environment universe_cmd(parser & p) {
|
||||||
name n = p.check_id_next("invalid universe declaration, identifier expected");
|
name n = p.check_id_next("invalid universe declaration, identifier expected");
|
||||||
check_atomic(n);
|
|
||||||
environment env = p.env();
|
environment env = p.env();
|
||||||
if (in_section_or_context(env)) {
|
if (in_section_or_context(env)) {
|
||||||
p.add_local_level(n, mk_param_univ(n));
|
p.add_local_level(n, mk_param_univ(n));
|
||||||
|
@ -119,7 +118,6 @@ environment variable_cmd_core(parser & p, bool is_axiom) {
|
||||||
auto pos = p.pos();
|
auto pos = p.pos();
|
||||||
optional<binder_info> bi = parse_binder_info(p);
|
optional<binder_info> bi = parse_binder_info(p);
|
||||||
name n = p.check_id_next("invalid declaration, identifier expected");
|
name n = p.check_id_next("invalid declaration, identifier expected");
|
||||||
check_atomic(n);
|
|
||||||
buffer<name> ls_buffer;
|
buffer<name> ls_buffer;
|
||||||
if (p.curr_is_token(g_llevel_curly) && in_section_or_context(p.env()))
|
if (p.curr_is_token(g_llevel_curly) && in_section_or_context(p.env()))
|
||||||
throw parser_error("invalid declaration, axioms/parameters occurring in sections cannot be universe polymorphic", p.pos());
|
throw parser_error("invalid declaration, axioms/parameters occurring in sections cannot be universe polymorphic", p.pos());
|
||||||
|
@ -211,7 +209,6 @@ environment definition_cmd_core(parser & p, bool is_theorem, bool _is_opaque) {
|
||||||
auto n_pos = p.pos();
|
auto n_pos = p.pos();
|
||||||
unsigned start_line = n_pos.first;
|
unsigned start_line = n_pos.first;
|
||||||
name n = p.check_id_next("invalid declaration, identifier expected");
|
name n = p.check_id_next("invalid declaration, identifier expected");
|
||||||
check_atomic(n);
|
|
||||||
decl_modifiers modifiers;
|
decl_modifiers modifiers;
|
||||||
name real_n; // real name for this declaration
|
name real_n; // real name for this declaration
|
||||||
modifiers.m_is_opaque = _is_opaque;
|
modifiers.m_is_opaque = _is_opaque;
|
||||||
|
@ -382,7 +379,6 @@ static environment variables_cmd(parser & p) {
|
||||||
buffer<name> ids;
|
buffer<name> ids;
|
||||||
while (!p.curr_is_token(g_colon)) {
|
while (!p.curr_is_token(g_colon)) {
|
||||||
name id = p.check_id_next("invalid parameters declaration, identifier expected");
|
name id = p.check_id_next("invalid parameters declaration, identifier expected");
|
||||||
check_atomic(id);
|
|
||||||
ids.push_back(id);
|
ids.push_back(id);
|
||||||
}
|
}
|
||||||
p.next();
|
p.next();
|
||||||
|
|
|
@ -121,9 +121,9 @@ struct inductive_cmd_fn {
|
||||||
name parse_decl_name(optional<name> const & ind_name) {
|
name parse_decl_name(optional<name> const & ind_name) {
|
||||||
m_pos = m_p.pos();
|
m_pos = m_p.pos();
|
||||||
name id = m_p.check_id_next("invalid declaration, identifier expected");
|
name id = m_p.check_id_next("invalid declaration, identifier expected");
|
||||||
check_atomic(id);
|
|
||||||
if (ind_name) {
|
if (ind_name) {
|
||||||
// for intro rules, we append the name of the inductive datatype
|
// for intro rules, we append the name of the inductive datatype
|
||||||
|
check_atomic(id);
|
||||||
name full_id = *ind_name + id;
|
name full_id = *ind_name + id;
|
||||||
m_decl_info.emplace_back(full_id, g_intro, m_pos);
|
m_decl_info.emplace_back(full_id, g_intro, m_pos);
|
||||||
return full_id;
|
return full_id;
|
||||||
|
|
29
tests/lean/run/ns2.lean
Normal file
29
tests/lean/run/ns2.lean
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
definition foo.id {A : Type} (a : A) := a
|
||||||
|
variable foo.T : Type.{1}
|
||||||
|
check foo.id
|
||||||
|
check foo.T
|
||||||
|
|
||||||
|
inductive foo.v.I := unit : foo.v.I
|
||||||
|
|
||||||
|
check foo.v.I
|
||||||
|
check foo.v.I.unit
|
||||||
|
|
||||||
|
namespace foo
|
||||||
|
check id
|
||||||
|
check T
|
||||||
|
check v.I
|
||||||
|
end foo
|
||||||
|
|
||||||
|
namespace bla
|
||||||
|
definition vvv.pr {A : Type} (a b : A) := a
|
||||||
|
check vvv.pr
|
||||||
|
end bla
|
||||||
|
check bla.vvv.pr
|
||||||
|
|
||||||
|
namespace bla
|
||||||
|
namespace vvv
|
||||||
|
check pr
|
||||||
|
inductive my.empty : Type
|
||||||
|
end vvv
|
||||||
|
end bla
|
||||||
|
check bla.vvv.my.empty
|
|
@ -10,7 +10,6 @@ Type
|
||||||
Type
|
Type
|
||||||
Type
|
Type
|
||||||
t3.lean:26:10: error: invalid namespace declaration, atomic identifier expected
|
t3.lean:26:10: error: invalid namespace declaration, atomic identifier expected
|
||||||
t3.lean:27:0: error: invalid declaration name 'full.name.U', identifier must be atomic
|
|
||||||
Type
|
Type
|
||||||
Type
|
Type
|
||||||
t3.lean:35:2: error: universe level alias 'u' shadows existing global universe level
|
t3.lean:35:2: error: universe level alias 'u' shadows existing global universe level
|
||||||
|
|
Loading…
Reference in a new issue