Skip to content

Commit e333f8d

Browse files
committed
Tolerate missing symbols in gather_needed_globals. Fixes #620
Symbols can be missing at this stage because they would be introduced during typechecking when it notices they are undefined, which happens if the type they were defined on is missing.
1 parent 29af567 commit e333f8d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,16 @@ static void gather_needed_globals(
387387
{
388388
if(e.id()==ID_symbol)
389389
{
390-
const auto &sym=symbol_table.lookup(to_symbol_expr(e).get_identifier());
391-
if(sym.is_static_lifetime)
392-
needed.add(sym);
390+
// If the symbol isn't in the symbol table at all, then it is defined
391+
// on an opaque type (i.e. we don't have the class definition at this point)
392+
// and will be created during the typecheck phase.
393+
// We don't mark it as 'needed' as it doesn't exist yet to keep.
394+
auto findit=symbol_table.symbols.find(to_symbol_expr(e).get_identifier());
395+
if(findit!=symbol_table.symbols.end() &&
396+
findit->second.is_static_lifetime)
397+
{
398+
needed.add(findit->second);
399+
}
393400
}
394401
else
395402
forall_operands(opit, e)

0 commit comments

Comments
 (0)