fix(frontends/lean/parser): segfault when ending scope without opening, fixes #244
This commit is contained in:
parent
4a9e725ca7
commit
d75a9c840c
4 changed files with 6 additions and 0 deletions
|
@ -46,6 +46,7 @@ public:
|
|||
std::tie(m_map, m_counter, m_entries) = head(m_scopes);
|
||||
m_scopes = tail(m_scopes);
|
||||
}
|
||||
bool has_scopes() const { return !is_nil(m_scopes); }
|
||||
bool empty() const { return m_map.empty(); }
|
||||
struct mk_scope {
|
||||
local_decls & m_d;
|
||||
|
|
|
@ -417,6 +417,9 @@ void parser::push_local_scope(bool save_options) {
|
|||
}
|
||||
|
||||
void parser::pop_local_scope() {
|
||||
if (!m_local_level_decls.has_scopes()) {
|
||||
throw parser_error("invalid 'end', there is no open namespace/section/context", pos());
|
||||
}
|
||||
m_local_level_decls.pop();
|
||||
m_local_decls.pop();
|
||||
lean_assert(!is_nil(m_parser_scope_stack));
|
||||
|
|
1
tests/lean/bad_end.lean
Normal file
1
tests/lean/bad_end.lean
Normal file
|
@ -0,0 +1 @@
|
|||
end foo
|
1
tests/lean/bad_end.lean.expected.out
Normal file
1
tests/lean/bad_end.lean.expected.out
Normal file
|
@ -0,0 +1 @@
|
|||
bad_end.lean:1:4: error: invalid 'end', there is no open namespace/section/context
|
Loading…
Reference in a new issue