MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / clearAllFunctionLookups

Function clearAllFunctionLookups

src/ast/ast_parse.cpp:667–673  ·  view source on GitHub ↗

`Function::lookup` keys cache entries by `intptr_t(structType)` via `getLookupHash(types)`. After gc sweep, freed Structure addresses can be reused by later allocations — a stale cached `false` then poisons the lookup for the new Structure at the same address, surfacing as a flaky "no matching functions or generics" on legitimate calls. Clear every function/generic cache before gc_guard sweeps.

Source from the content-addressed store, hash-verified

665 // "no matching functions or generics" on legitimate calls. Clear every
666 // function/generic cache before gc_guard sweeps.
667 static void clearAllFunctionLookups() {
668 Module::foreach([](Module * m) -> bool {
669 m->functions.foreach([](auto & fn) { fn->lookup.clear(); });
670 m->generics.foreach([](auto & fn) { fn->lookup.clear(); });
671 return true;
672 });
673 }
674
675 // compileDaScript runs its top-level post-parse steps (deriveAliases/allocateStack/...)
676 // on a transient gc_guard root; on exit this merges that scratch into the program's

Callers 2

~GcCollectOnExitMethod · 0.85
~ModuleGcFinalizeMethod · 0.85

Calls 2

foreachMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected