DeepFix: Fixing Common C Language Errors by Deep Learning
Please follow https://bitbucket.org/iiscseal/deepfix for the latest updates.
The problem of automatically fixing programming errors is a very active research topic in software engineering. This is a challenging problem as fixing even a single error may require analysis of the entire program. In practice, a number of errors arise due to programmer’s inexperience with the programming language or lack of attention to detail. We call these common programming errors. These are analogous to grammatical errors in natural languages.
Compilers detect such errors, but their error messages are usually inaccurate. In this work, we present an end-to-end solution, called DeepFix, that can fix multiple such errors in a program without relying on any external tool to locate or fix them. At the heart of DeepFix is a multi-layered sequence-to-sequence neural network with attention which is trained to predict erroneous program locations along with the required correct statements. On a set of 6971 erroneous C programs written by students for 93 programming tasks, DeepFix could fix 1881 (27%) programs completely and 1338 (19%) programs partially.
The image below shows an example of DeepFix in action. The input program consists of several errors. We show the Fixes suggested by DeepFix below the program.
A compiler can detect the errors in the above program but compiler error messages can be anywhere from unhelpful to misleading. This makes it difficult for novices (who are new to the syntax of the language) to debug their code. Below, we show the error messages that GCC generates for the same input program.
The implementation of DeepFix is available at the BitBucket repository: https://bitbucket.org/iiscseal/deepfix. To set up and use DeepFix, please follow the instructions in the README. In our experience, training the network requires at least 100,000 examples and about 15 epochs of training.
Rahul Gupta, Soham Pal, Aditya Kanade, Shirish Shevade
We thank Google for a student travel grant to support travel to present this work at AAAI 2017. We are grateful to Amey Karkare and Umair Z. Ahmed of the Indian Institute of Technology, Kanpur for providing us the student solutions to experiment with.
DeepFix is available under the Apache License, version 2.0.