B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections. Squash of 94 local commits onto remote master.
1.2 KiB
1.2 KiB
| id | repo | severity | status | created | patched | patch |
|---|---|---|---|---|---|---|
| ghc-0004 | ghc | MEDIUM | PATCHED | 2026-03-23 | 2026-03-23 | defects/ghc/patch/ghc-cwe407-set-membership.patch |
Defect
File: compiler/GHC/Tc/TyCl/Utils.hs:973
Pattern: elem in constructor list during type-class checking
Complexity: O(n) per check
Language: Haskell
Description
During type-class checking, GHC tests whether a data constructor is in a list using elem, which performs a linear scan. This check is applied per-constructor during the verification of derived instances and type-class obligations. For data types with many constructors, or when checks are repeated across multiple class instances, the O(n) per-check cost accumulates into noticeable compilation slowdown.
Fix
Replace: con `elem` conList
With: con `S.member` conSet
Data structure change: conList: [DataCon] → conSet: Set DataCon
Work required
- Patch in
defects/ghc/patch/ - Unit test — asserts exact operation counts before/after (in
defects/ghc/unit/) - Integration test (in
defects/ghc/integration/) - Benchmark — before/after on V=100,200,400,800 (in
defects/ghc/bench/) - White paper section