Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type Errors
As a dynamic programming language, Python has become increasingly popular in recent years. Although the dynamic type system of Python facilitates the developers in writing Python programs, it also brings type errors at run-time which are prevalent yet not easy to fix. There exist rule-based approaches for automatically repairing Python type errors. The approaches can generate accurate patches for the type errors covered by manually defined templates, but they require domain experts to design patch synthesis rules and suffer from low template coverage of real-world type errors. Learning-based approaches alleviate the manual efforts in designing patch synthesis rules and have become prevalent due to the recent advances in deep learning. Among the learning-based approaches, the prompt-based approach which leverages the knowledge base of code pre-trained models via pre-defined prompts, obtains state-of-the-art performance in general program repair tasks. However, such prompts are manually defined and do not involve any specific clues for repairing Python type errors, resulting in limited effectiveness. How to automatically improve prompts with the domain knowledge for type error repair is challenging yet under-explored.
In this paper, we present TypeFix, a novel prompt-based approach with fix templates incorporated for repairing Python type errors. TypeFix first mines generalized fix templates via a novel hierarchical clustering algorithm. The identified fix templates indicate the common edit patterns and contexts of existing type error fixes. TypeFix then generates code prompts for code pre-trained models by employing the generalized fix templates as domain knowledge, in which the masks are adaptively located for each type error instead of being pre-determined. Experiments on two benchmarks, including BugsInPy and TypeBugs, show that TypeFix successfully repairs 26 and 55 type errors, outperforming the best baseline approach by 9 and 14, respectively. Besides, the proposed fix template mining approach can cover 75% of developers’ patches in both benchmarks, increasing the best rule-based approach PyTER by more than 30%.
Wed 17 AprDisplayed time zone: Lisbon change
11:00 - 12:30 | Program Repair 1Research Track / Journal-first Papers / Industry Challenge Track at Pequeno Auditório Chair(s): Sergey Mechtaev University College London | ||
11:00 15mTalk | Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type Errors Research Track Yun Peng The Chinese University of Hong Kong, Shuzheng Gao The Chinese University of Hong Kong, Cuiyun Gao Harbin Institute of Technology, Yintong Huo The Chinese University of Hong Kong, Michael Lyu The Chinese University of Hong Kong | ||
11:15 15mTalk | VeRe: Verification Guided Synthesis for Repairing Deep Neural Networks Research Track Jianan Ma Hangzhou Dianzi University, China; Zhejiang University, Hangzhou, China, Pengfei Yang Institute of Software at Chinese Academy of Sciences, China, Jingyi Wang Zhejiang University, Youcheng Sun The University of Manchester, Cheng-Chao Huang Nanjing Institute of Software Technology, ISCAS, Zhen Wang Hangzhou Dianzi University, China | ||
11:30 15mTalk | Automated Program Repair, What Is It Good For? Not Absolutely Nothing! Research Track Hadeel Eladawy University of Massachusetts, Claire Le Goues Carnegie Mellon University, Yuriy Brun University of Massachusetts DOI Pre-print Media Attached | ||
11:45 15mTalk | When Large Language Models Confront Repository-Level Automatic Program Repair: How Well They Done? Industry Challenge Track YuXiao Chen Institute of Software, Chinese Academy of Sciences, Jingzheng Wu Institute of Software, The Chinese Academy of Sciences, Xiang Ling Institute of Software, Chinese Academy of Sciences, Changjiang Li Penn State, ZHIQING RUI Institute of Software, Chinese Academy of Sciences; University of Chinese Academy of Sciences, Tianyue Luo Institute of Software, Chinese Academy of Sciences, Yanjun Wu Institute of Software, Chinese Academy of Sciences | ||
12:00 7mTalk | Katana: Dual Slicing Based Context for Learning Bug Fixes Journal-first Papers Mifta Sintaha University of British Columbia, Noor Nashid University of British Columbia, Ali Mesbah University of British Columbia (UBC) Link to publication Pre-print | ||
12:07 7mTalk | Poracle: Testing Patches Under Preservation Conditions to Combat the Overfitting Problem of Program Repair Journal-first Papers Elkhan Ismayilzada UNIST, Md Mazba Ur Rahman UNIST, Dongsun Kim Kyungpook National University, Jooyong Yi UNIST | ||
12:14 7mTalk | APR4Vul: An empirical study of automatic program repair techniques on real-world Java vulnerabilities Journal-first Papers Quang-Cuong Bui Hamburg University of Technology, Ranindya Paramitha University of Trento, Duc-Ly Vu University of Information Technology, Ho Chi Minh City, Fabio Massacci University of Trento; Vrije Universiteit Amsterdam, Riccardo Scandariato Hamburg University of Technology DOI Pre-print |