GPT-3-Powered Type Error Debugging: Investigating the Use of Large Language Models for Code Repair

被引:11
作者
Ribeiro, Francisco [1 ]
Castro de Macedo, Jose Nuno [1 ]
Tsushima, Kanae [2 ]
Abreu, Rui [3 ]
Saraiva, Joao [1 ]
机构
[1] Univ Minho, HASLab, INESC TEC, Braga, Portugal
[2] Sokendai Univ, Natl Inst Informat, Tokyo, Japan
[3] Univ Porto, INESC ID, Porto, Portugal
来源
PROCEEDINGS OF THE 16TH ACM SIGPLAN INTERNATIONAL CONFERENCE ON SOFTWARE LANGUAGE ENGINEERING, SLE 2023 | 2023年
关键词
Automated Program Repair; GPT-3; Fault Localization; Code Generation;
D O I
10.1145/3623476.3623522
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Type systems are responsible for assigning types to terms in programs. That way, they enforce the actions that can be taken and can, consequently, detect type errors during compilation. However, while they are able to flag the existence of an error, they often fail to pinpoint its cause or provide a helpful error message. Thus, without adequate support, debugging this kind of errors can take a considerable amount of effort. Recently, neural network models have been developed that are able to understand programming languages and perform several downstream tasks. We argue that type error debugging can be enhanced by taking advantage of this deeper understanding of the language's structure. In this paper, we present a technique that leverages GPT-3's capabilities to automatically fix type errors in OCaml programs. We perform multiple source code analysis tasks to produce useful prompts that are then provided to GPT-3 to generate potential patches. Our publicly available tool, Mentat, supports multiple modes and was validated on an existing public dataset with thousands of OCaml programs. We automatically validate successful repairs by using Quickcheck to verify which generated patches produce the same output as the user-intended fixed version, achieving a 39% repair rate. In a comparative study, Mentat outperformed two other techniques in automatically fixing ill-typed OCaml programs.
引用
收藏
页码:111 / 124
页数:14
相关论文
共 52 条
  • [1] code2vec: Learning Distributed Representations of Code
    Alon, Uri
    Zilberstein, Meital
    Levy, Omer
    Yahav, Eran
    [J]. PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2019, 3 (POPL):
  • [2] Revisiting the Practical Use of Automated Software Fault Localization Techniques
    Ang, Aaron
    Perez, Alexandre
    van Deursen, Arie
    Abreu, Rui
    [J]. 2017 IEEE 28TH INTERNATIONAL SYMPOSIUM ON SOFTWARE RELIABILITY ENGINEERING WORKSHOPS (ISSREW 2017), 2017, : 175 - 182
  • [3] [Anonymous], 2002, Types and Programming Languages
  • [4] [Anonymous], 2011, Proceedings of the 2011 International Symposium on Software Testing and Analysis, DOI DOI 10.1145/2001420.2001445
  • [5] Evolutionary repair of faulty software
    Arcuri, Andrea
    [J]. APPLIED SOFT COMPUTING, 2011, 11 (04) : 3494 - 3514
  • [6] Brown TB, 2020, Arxiv, DOI arXiv:2005.14165
  • [7] Campos J, 2012, IEEE INT CONF AUTOM, P378, DOI 10.1145/2351676.2351752
  • [8] Chen S, 2014, LECT NOTES COMPUT SC, V8475, P35, DOI 10.1007/978-3-319-07151-0_3
  • [9] Counter-Factual Typing for Debugging Type Errors
    Chen, Sheng
    Erwig, Martin
    [J]. ACM SIGPLAN NOTICES, 2014, 49 (01) : 583 - 594
  • [10] SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair
    Chen, Zimin
    Kommrusch, Steve
    Tufano, Michele
    Pouchet, Louis-Noel
    Poshyvanyk, Denys
    Monperrus, Martin
    [J]. IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2021, 47 (09) : 1943 - 1959