B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections. Squash of 94 local commits onto remote master.
1.3 KiB
| id | repo | severity | status | patched | patch | created |
|---|---|---|---|---|---|---|
| ts-0003 | TypeScript | HIGH | PATCHED | 2026-03-23 | defects/typescript/patch/ts-checker-set-visited.patch | 2026-03-23 |
Defect
File: src/compiler/checker.ts:5763
Pattern: pushIfUnique(visitedSymbolTables, ...) array in symbol table merging
Complexity: O(depth²)
Language: TypeScript
Description
Symbol table merging uses pushIfUnique on a visitedSymbolTables array to prevent re-visiting the same symbol table during recursive resolution. Each call to pushIfUnique scans the entire array linearly to check for existing membership. As merge depth increases, the array grows and each check becomes more expensive, resulting in O(depth²) total work across the recursive calls.
Fix
Replace: pushIfUnique(visitedSymbolTables, table)
With: visitedSymbolTables.add(table) (with early-return on has check)
Data structure change: visitedSymbolTables: SymbolTable[] → visitedSymbolTables: Set<SymbolTable>
Work required
- Patch in
defects/typescript/patch/ - Unit test — asserts exact operation counts before/after (in
defects/typescript/unit/) - Integration test (in
defects/typescript/integration/) - Benchmark — before/after on V=100,200,400,800 (in
defects/typescript/bench/) - White paper section