@@ -172,18 +172,26 @@ typet verilog_typecheck_exprt::elaborate_package_scope_typedef(
172172 << " verilog_package_scope expects typedef_type on the rhs" ;
173173
174174 auto package_base_name = src.subtypes ()[0 ].id ();
175- auto typedef_base_name = src.subtypes ()[1 ].get (ID_base_name);
175+ auto typedef_base_name =
176+ to_verilog_typedef_type (src.subtypes ()[1 ]).base_name ();
176177
177178 // stitch together
178179 irep_idt full_identifier =
179180 id2string (verilog_package_identifier (package_base_name)) + ' .' +
180181 id2string (typedef_base_name);
181182
182- // recursive call
183- verilog_typedef_typet full_typedef_type (full_identifier);
184- full_typedef_type.set (ID_identifier, full_identifier);
183+ // look it up
184+ const symbolt *symbol_ptr;
185185
186- return elaborate_type (full_typedef_type);
186+ if (ns.lookup (full_identifier, symbol_ptr))
187+ throw errort ().with_location (location)
188+ << " symbol " << typedef_base_name << " not found in package" ;
189+
190+ // must be type
191+ if (!symbol_ptr->is_type )
192+ throw errort ().with_location (location) << " expected a type identifier" ;
193+
194+ return symbol_ptr->type ;
187195}
188196
189197/* ******************************************************************\
@@ -334,18 +342,17 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
334342 else if (src.id () == ID_typedef_type)
335343 {
336344 // Look it up!
337- const symbolt *symbol_ptr;
338-
339- auto identifier = to_verilog_typedef_type (src).identifier ();
345+ auto base_name = to_verilog_typedef_type (src).base_name ();
346+ const auto *symbol_ptr = resolve (base_name);
340347
341- if (ns. lookup (identifier, symbol_ptr) )
348+ if (symbol_ptr == nullptr )
342349 throw errort ().with_location (source_location)
343- << " type symbol " << identifier << " not found" ;
350+ << " type symbol " << base_name << " not found" ;
344351
345352 DATA_INVARIANT (symbol_ptr->is_type , " typedef symbols must be types" );
346353
347354 // elaborate that typedef symbol, recursively, if needed
348- elaborate_symbol_rec (identifier );
355+ elaborate_symbol_rec (symbol_ptr-> name );
349356
350357 auto result = symbol_ptr->type ; // copy
351358 return result.with_source_location (source_location);
0 commit comments