feat(frontends/lean/definition_cmds): hide scary kernel exception on duplicate declaration

This commit is contained in:
Sebastian Ullrich 2017-12-17 21:47:05 +01:00 committed by Leonardo de Moura
parent a4db338053
commit c600bca747

View file

@ -249,6 +249,9 @@ declare_definition(parser & p, environment const & env, decl_cmd_kind kind, buff
} else {
c_real_name = get_namespace(env) + c_name;
}
if (env.find(c_real_name)) {
throw exception(sstream() << "invalid definition, a declaration named '" << c_real_name << "' has already been declared");
}
if (val && !meta.m_modifiers.m_is_meta && !type_checker(env).is_prop(type)) {
/* We only abstract nested proofs if the type of the definition is not a proposition */
std::tie(new_env, type) = abstract_nested_proofs(new_env, c_real_name, type);