Large Language Models of Code Fail at Completing Code with Potential Bugs

Tuan Dinh, Jinman Zhao, Samson Tan, Renato M. P. Negrinho, Leonard Lausen +2 more
2/12/2026

No official code found. Best implementation: amazon-science/buggy-code-completion (4 stars, Apache-2.0, last commit 2023-12-13).

Abstract

Large language models of code (Code-LLMs) have recently brought tremendous advances to code completion, a fundamental feature of programming assistance and code intelligence. However, most existing works ignore the possible presence of bugs in the code context for generation, which are inevitable in software development. Therefore, we introduce and study the buggy-code completion problem, inspired by the realistic scenario of real-time code suggestion where the code context contains potential bugs -- anti-patterns that can become bugs in the completed program. To systematically study the task, we introduce two datasets: one with synthetic bugs derived from semantics-altering operator changes (buggy-HumanEval) and one with realistic bugs derived from user submissions to coding problems (buggy-FixEval). We find that the presence of potential bugs significantly degrades the generation performance of the high-performing Code-LLMs. For instance, the passing rates of CODEGEN-2B-MONO on test cases of buggy-HumanEval drop more than 50% given a single potential bug in the context. Finally, we investigate several post-hoc methods for mitigating the adverse effect of potential bugs and find that there remains a significant gap in post-mitigation performance.

View on arXivView PDF

Code Implementations(1)

Apache-2.0
42Shell, PythonNov 29, 20232 years agoApache-2.0

Similar Papers

Cite this paper

@article{dinh2026large,
  title  = {Large Language Models of Code Fail at Completing Code with Potential Bugs},
  author = {Tuan Dinh and Jinman Zhao and Samson Tan and Renato M. P. Negrinho and Leonard Lausen and Sheng Zha and G. Karypis},
  year   = {2026},
  eprint = {2306.03438},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2306.03438},
  journal = {NEURIPS 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.03438.svg)](https://codeofpaper.com/paper/2306.03438)

Discussion