一句话:揭示动态类型语言缺陷数据集中类型相关缺陷占比,并证明神经缺陷检测器与类型检查结合可提升检测效果。
动态类型语言(如 Python)缺少强制类型标注,传统静态分析难以早期发现缺陷,因此神经缺陷检测器受到关注;然而已有工作在训练与测试时忽略了可选类型检查器的作用,可能造成性能评估偏差并使检测焦点偏移。本文对现有合成与真实数据集进行类型检查,量化类型相关缺陷的占比,并系统研究其对多种面向变量误用缺陷的神经缺陷检测器训练与测试的影响。结果发现:现有数据集含有大量类型相关缺陷;将类型检查器与神经检测器结合尤其在有类型标注时有益;神经检测器在类型相关缺陷上表现更好;从训练数据中移除类型相关缺陷,反而能提升其发现类型检查器范围之外缺陷的能力。
[Motivation] Automated bug detection in dynamically typed languages such as Python is essential for maintaining code quality. The lack of mandatory type annotations in such languages can lead to errors that are challenging to identify early with traditional static analysis tools. Recent progress in deep neural networks has led to increased use of neural bug detectors. In statically typed languages, a type checker is integrated into the compiler and thus taken into consideration when the neural bug detector is designed for these languages. [Problem] However, prior studies overlook this aspect during the training and testing of neural bug detectors for dynamically typed languages. When an optional type checker is used, assessing existing neural bug detectors on bugs easily detectable by type checkers may impact their performance estimation. Moreover, including these bugs in the training set of neural bug detectors can shift their detection focus toward the wrong type of bugs. [Contribution] We explore the impact of type checking on various neural bug detectors for variable misuse bugs, a common type targeted by neural bug detectors. Existing synthetic and real-world datasets are type-checked to evaluate the prevalence of type-related bugs. Then, we investigate how type-related bugs influence the training and testing of the neural bug detectors. [Findings] Our findings indicate that existing bug detection datasets contain a significant proportion of type-related bugs. Building on this insight, we discover integrating the neural bug detector with a type checker can be beneficial, especially when the code is annotated with types. Further investigation reveals neural bug detectors perform better on type-related bugs than other bugs. Moreover, removing type-related bugs from the training data helps improve neural bug detectors' ability to identify bugs beyond the scope of type checkers.
DOI 原文 ·
@inproceedings{paperbot8699,
title = {The Power of Types: Exploring the Impact of Type Checking on Neural Bug Detection in Dynamically Typed Languages},
author = {Boqi Chen and José Antonio Hernández López and Gunter Mussbacher and Dániel Varró},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00088}
}