Replace an assert with an internal error message.

This commit is contained in:
Stephen Williams 2019-10-03 08:38:36 -07:00
parent 4f48a7ed41
commit 2ced291d33
1 changed files with 15 additions and 0 deletions

View File

@ -2356,7 +2356,22 @@ void pform_make_modgates(const struct vlltype&loc,
svector<lgate>*gates,
std::list<named_pexpr_t>*attr)
{
// The grammer should not allow module gates to happen outside
// an active module. But if really bad input errors combine in
// an ugly way with error recovery, then catch this
// implausible situation and return an error.
if (pform_cur_module.empty()) {
cerr << loc << ": internal error: "
<< "Module instantiations outside module scope are not possible."
<< endl;
error_count += 1;
delete gates;
return;
}
assert(! pform_cur_module.empty());
// Detect some more realistic errors.
if (pform_cur_module.front()->program_block) {
cerr << loc << ": error: Module instantiations are not allowed in "
<< "program blocks." << endl;