fix: reject inductive datatypes with duplicate constructor names

This commit is contained in:
Leonardo de Moura 2019-12-14 09:11:39 -08:00
parent 38d2cffa7e
commit 6ae510cea4

View file

@ -347,8 +347,13 @@ public:
void check_constructors() {
for (unsigned idx = 0; idx < m_ind_types.size(); idx++) {
inductive_type const & ind_type = m_ind_types[idx];
name_set found_cnstrs;
for (constructor const & cnstr : ind_type.get_cnstrs()) {
name const & n = constructor_name(cnstr);
if (found_cnstrs.contains(n)) {
throw kernel_exception(m_env, sstream() << "duplicate constructor name '" << n << "'");
}
found_cnstrs.insert(n);
expr t = constructor_type(cnstr);
m_env.check_name(n);
check_no_metavar_no_fvar(m_env, n, t);