RetypeR: Integrated Retrieval-based Automatic Program Repair for Python Type Errors
Authors:
- 6 October 2024
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 199-210
Abstract
Python is a widely popular dynamic programming language. While Python's dynamic type system facilitates the development of Python programs, it also introduces type errors at run-time which are often challenging to repair. Large language models (LLMs) have recently demonstrated impressive performance in code understanding and generation, and have been applied to patch synthesis. However, the ability of LLMs to repair type errors is often limited by their finite input context window, which may not fully encompass the repair information necessary for fixing a specific type error, such as valuable context code and fix patterns. In this paper, we introduce RetypeR, an integrated retrieval-based framework to repair Python type errors automatically. RetypeR comprises two stages: external retrieval and internal retrieval. The external retrieval stage retrieves applicable fix patterns from external code repositories containing historical error fixes via an abstract syntax tree (AST)-based retrieval strategy. In the internal retrieval stage, a novel fix ingredient retriever is designed to extract valuable repair ingredients from local context within source files based on both lexical and semantic similarity. To integrate the information retrieved from the aforementioned external and internal stages, RetypeR constructs context-aware repair prompts for LLMs to guide them in generating correct patches for type errors. We evaluate RetypeR on two real-world benchmarks, TypeBugs and BugsInPy. The experimental results demonstrate that RetypeR achieves state-of-the-art performance, improving the best baseline by 12.73% and 11.54% on TypeBugs and BugsInPy benchmarks, respectively.Keywords
Funding Information
- National Key Research and Development Program of China (2022YFC3301800)
This publication has 55 references indexed in Scilit:
- Generative Type Inference for Python2023
- Gamma: Revisiting Template-Based Automated Program Repair Via Mask Prediction2023
- What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?2023
- The Plastic Surgery Hypothesis in the Era of Large Language Models2023
- An Empirical Study on Fine-Tuning Large Language Models of Code for Automated Program Repair2023
- Impact of Code Language Models on Automated Program Repair2023
- Automated Program Repair in the Era of Large Pre-trained Language Models2023
- Where were the repair ingredients for Defects4j bugs?Empirical Software Engineering, 2021
- CURE: Code-Aware Neural Machine Translation for Automatic Program Repair2021
- FixMiner: Mining relevant fix patterns for automated program repairEmpirical Software Engineering, 2020