Replace an assert with an internal error message.

(cherry picked from commit 2ced291d33)
This commit is contained in:
Stephen Williams 2019-10-03 08:38:36 -07:00
parent c2bd35d277
commit 756674aa5b
1 changed files with 15 additions and 0 deletions

View File

@ -2338,7 +2338,22 @@ void pform_make_modgates(const struct vlltype&loc,
struct parmvalue_t*overrides,
svector<lgate>*gates)
{
// 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;