From 2ced291d330361cf3cb2c8a60a05d9f660310d4a Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 3 Oct 2019 08:38:36 -0700 Subject: [PATCH] Replace an assert with an internal error message. --- pform.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pform.cc b/pform.cc index c8a42bb17..d9772dd70 100644 --- a/pform.cc +++ b/pform.cc @@ -2356,7 +2356,22 @@ void pform_make_modgates(const struct vlltype&loc, svector*gates, std::list*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;