Commit 3a748efd
3a748efd0df5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
analyze: DCE backstop for BFS-reachable methods with TY_UNKNOWN params
BFS reachability marks all scopes with a given method name as reachable when that name is called anywhere. This over-approximates: a method may be name-matched but never have typed call sites bind its parameters, leaving them as TY_UNKNOWN, which causes exit(1) in codegen.
Add a post-fixpoint backstop that marks such methods unreachable so codegen silently skips them rather than crashing. This converts several ERR tests to PASS by allowing the rest of the program to compile when dead overloads have unresolvable param types.
Tests: 705 pass, 3 fail, 137 error (was 697/7/141)
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 3a748efd0df5
- Parent
- 4a2c4a5c9aa3
src/analyze.cmodifiedView file
} } /* Backstop: a reachable method still has TY_UNKNOWN params if it was never called with typed arguments (BFS marked it live by name, but no typed call site bound its args). Mark such methods unreachable so codegen skips them rather than exit(1)ing on the unknown type. */ for (int s = 0; s < c->nscopes; s++) { Scope *sc = &c->scopes[s]; if (!sc->reachable || sc->nparams == 0) continue; int has_unknown = 0; for (int i = 0; i < sc->nparams; i++) { LocalVar *p = sc->pnames[i] ? scope_local(sc, sc->pnames[i]) : NULL; if (p && p->type == TY_UNKNOWN) { has_unknown = 1; break; } } if (has_unknown) sc->reachable = 0; } /* finalize: gc-root needs + full node type cache */ for (int s = 0; s < c->nscopes; s++) for (int i = 0; i < c->scopes[s].nlocals; i++)