fix(frontends/lean): make sure typing information is sorted, make sure the error messages contains line file name
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
c6f3232f81
commit
b56233cbe3
4 changed files with 13 additions and 2 deletions
|
@ -54,7 +54,8 @@ info_manager::info_manager():m_sorted_upto(0) {}
|
||||||
void info_manager::sort_core() {
|
void info_manager::sort_core() {
|
||||||
if (m_sorted_upto == m_data.size())
|
if (m_sorted_upto == m_data.size())
|
||||||
return;
|
return;
|
||||||
std::stable_sort(m_data.begin() + m_sorted_upto, m_data.end());
|
std::stable_sort(m_data.begin() + m_sorted_upto, m_data.end(),
|
||||||
|
[](std::unique_ptr<info_data> const & i1, std::unique_ptr<info_data> const & i2) { return *i1 < *i2; });
|
||||||
m_sorted_upto = m_data.size();
|
m_sorted_upto = m_data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ void info_manager::invalidate(unsigned sline) {
|
||||||
sort_core();
|
sort_core();
|
||||||
unsigned i = find(sline, 0);
|
unsigned i = find(sline, 0);
|
||||||
m_data.resize(i);
|
m_data.resize(i);
|
||||||
m_sorted_upto = m_data.size();
|
if (m_data.size() < m_sorted_upto)
|
||||||
|
m_sorted_upto = m_data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void info_manager::add_core(std::unique_ptr<info_data> && d) {
|
void info_manager::add_core(std::unique_ptr<info_data> && d) {
|
||||||
|
|
|
@ -174,6 +174,7 @@ void parser::throw_nested_exception(exception & ex, pos_info p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CATCH(ShowError, ThrowError) \
|
#define CATCH(ShowError, ThrowError) \
|
||||||
|
save_pre_info_data(); \
|
||||||
m_found_errors = true; \
|
m_found_errors = true; \
|
||||||
if (!m_use_exceptions && m_show_errors) { ShowError ; } \
|
if (!m_use_exceptions && m_show_errors) { ShowError ; } \
|
||||||
sync(); \
|
sync(); \
|
||||||
|
@ -192,6 +193,7 @@ void parser::protected_call(std::function<void()> && f, std::function<void()> &&
|
||||||
CATCH(display_error(ex.what(), ex.m_pos),
|
CATCH(display_error(ex.what(), ex.m_pos),
|
||||||
throw_parser_exception(ex.what(), ex.m_pos));
|
throw_parser_exception(ex.what(), ex.m_pos));
|
||||||
} catch (interrupted & ex) {
|
} catch (interrupted & ex) {
|
||||||
|
save_pre_info_data();
|
||||||
reset_interrupt();
|
reset_interrupt();
|
||||||
if (m_verbose)
|
if (m_verbose)
|
||||||
regular_stream() << "!!!Interrupted!!!" << endl;
|
regular_stream() << "!!!Interrupted!!!" << endl;
|
||||||
|
@ -1165,6 +1167,7 @@ bool parser::parse_commands() {
|
||||||
break;
|
break;
|
||||||
case scanner::token_kind::ScriptBlock:
|
case scanner::token_kind::ScriptBlock:
|
||||||
parse_script();
|
parse_script();
|
||||||
|
save_snapshot();
|
||||||
break;
|
break;
|
||||||
case scanner::token_kind::Eof:
|
case scanner::token_kind::Eof:
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -1192,10 +1195,14 @@ void parser::add_delayed_theorem(environment const & env, name const & n, level_
|
||||||
}
|
}
|
||||||
|
|
||||||
void parser::save_snapshot() {
|
void parser::save_snapshot() {
|
||||||
|
m_pre_info_data.clear();
|
||||||
if (!m_snapshot_vector)
|
if (!m_snapshot_vector)
|
||||||
return;
|
return;
|
||||||
if (m_snapshot_vector->empty() || static_cast<int>(m_snapshot_vector->back().m_line) != m_scanner.get_line())
|
if (m_snapshot_vector->empty() || static_cast<int>(m_snapshot_vector->back().m_line) != m_scanner.get_line())
|
||||||
m_snapshot_vector->push_back(snapshot(m_env, m_local_level_decls, m_local_decls, m_ios.get_options(), m_scanner.get_line()));
|
m_snapshot_vector->push_back(snapshot(m_env, m_local_level_decls, m_local_decls, m_ios.get_options(), m_scanner.get_line()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void parser::save_pre_info_data() {
|
||||||
// if elaborator failed, then m_pre_info_data contains type information before elaboration.
|
// if elaborator failed, then m_pre_info_data contains type information before elaboration.
|
||||||
if (m_info_manager) {
|
if (m_info_manager) {
|
||||||
m_info_manager->append(m_pre_info_data, false);
|
m_info_manager->append(m_pre_info_data, false);
|
||||||
|
|
|
@ -156,6 +156,7 @@ class parser {
|
||||||
void save_snapshot();
|
void save_snapshot();
|
||||||
void save_overload(expr const & e);
|
void save_overload(expr const & e);
|
||||||
void save_type_info(expr const & e);
|
void save_type_info(expr const & e);
|
||||||
|
void save_pre_info_data();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
parser(environment const & env, io_state const & ios,
|
parser(environment const & env, io_state const & ios,
|
||||||
|
|
|
@ -84,6 +84,7 @@ void server::read_file(std::string const & fname) {
|
||||||
if (in.bad() || in.fail()) {
|
if (in.bad() || in.fail()) {
|
||||||
std::cout << "Error: failed to open file '" << fname << "'";
|
std::cout << "Error: failed to open file '" << fname << "'";
|
||||||
} else {
|
} else {
|
||||||
|
m_fname = fname;
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
for (std::string line; std::getline(in, line);) {
|
for (std::string line; std::getline(in, line);) {
|
||||||
m_lines.push_back(line);
|
m_lines.push_back(line);
|
||||||
|
|
Loading…
Reference in a new issue