Validating Soundness and Completeness in Pattern-Match Coverage Analyzers
Cyril Moser, Thodoris Sotiropoulos, Chengyu Zhang, Zhendong Su
Abstract
Pattern matching is a powerful mechanism for writing safe and expressive conditional logic. Once primarily associated with functional programming, it has become a common paradigm even in non-functional languages, such as Java. Languages that support pattern matching include specific analyzers, known as pattern-match coverage analyzers, to ensure its correct and efficient use by statically verifying properties such as exhaustiveness and redundancy. However, these analyzers can suffer from soundness and completeness issues, leading to false negatives (unsafe patterns mistakenly accepted) or false positives (valid patterns incorrectly rejected). In this work, we present a systematic approach for validating soundness and completeness in pattern-match coverage analyzers. The approach consists of a novel generator for algebraic data types and pattern-matching statements, supporting features that increase the complexity of coverage analysis, such as generalized algebraic data types. To establish the test oracle without building a reference implementation from scratch, the approach generates both exhaustive and inexhaustive pattern-matching cases, either by construction or by encoding them as SMT formulas. The latter leads to a universal test oracle that cross-checks coverage analysis results against a constraint solver, exposing soundness and completeness bugs in case of inconsistencies. We implement this approach in Ikaros , which we evaluate on three major compilers: Scala, Java, and Haskell. Despite pattern-match coverage analyzers being only a small part of these compilers, Ikaros has uncovered 16 bugs, of which 12 have been fixed. Notably, 7 instances were important soundness bugs that could lead to unexpected runtime errors. Additionally, Ikaros provides a scalable framework for extending it to any language with ML-like pattern matching.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get f4d0e8ad-ca0b-4583-81cf-e6bf1563ac0cRelated papers
- Constraint-Based Test Oracles for Program AnalyzersMarkus Fleischmann, David Kaindlstorfer, Anastasia Isychev, Valentin Wüstholz et al.ASE 2024 · 2 citations
- Intensional datatype refinement: with application to scalable verification of pattern-match safetyEddie Jones, Steven J. RamsayPOPL 2021 · 3 citations
- Finding typing compiler bugsStefanos Chaliasos, Thodoris Sotiropoulos, Diomidis Spinellis, Arthur Gervais et al.PLDI 2022 · 36 citations
- Modular Type Safety for Traits with Extensible Variants and Deep Pattern MatchingAndong Fan, Lionel Parreaux, Ningning XieOOPSLA 2026
- JavaDL: automatically incrementalizing Java bug pattern detectionAlexandru Dura, Christoph Reichenbach, Emma SöderbergOOPSLA 2021 · 13 citations
