{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,11,5]],"date-time":"2026-11-05T02:10:53Z","timestamp":1793844653421,"version":"4.6.1"},"reference-count":56,"publisher":"Association for Computing Machinery (ACM)","issue":"4","license":[{"start":{"date-parts":[[2025,4,28]],"date-time":"2025-04-28T00:00:00Z","timestamp":1745798400000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/www.acm.org\/publications\/policies\/copyright_policy#Background"}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["ACM Trans. Softw. Eng. Methodol."],"published-print":{"date-parts":[[2025,5,31]]},"abstract":"<jats:p>Technical Q&amp;A sites are valuable for software developers seeking knowledge, but the code snippets they provide are often uncompilable and incomplete due to unresolved types and missing libraries. This poses a challenge for users who wish to reuse or analyze these snippets. Existing methods either do not focus on creating compilable code or have low success rates. To address this, we propose ZS4C, a lightweight approach for zero-shot synthesis of compilable code from incomplete snippets using Large Language Models (LLMs). ZS4C operates in two stages: first, it uses an LLM, like GPT-3.5, to identify missing import statements in a snippet; second, it collaborates with a validator (e.g., compiler) to fix compilation errors caused by incorrect imports and syntax issues. We evaluated ZS4C on the StatType-SO benchmark and a new dataset, Python-SO, which includes 539 Python snippets from Stack Overflow across the 20 most popular Python libraries. ZS4C significantly outperforms existing methods, improving the compilation rate from 63% to 95.1% compared to the state-of-the-art SnR, marking a 50.1% improvement. On average, ZS4C can infer more accurate import statements (with an F1 score of 0.98) than SnR, with an improvement of 8.5% in the F1.<\/jats:p>","DOI":"10.1145\/3702979","type":"journal-article","created":{"date-parts":[[2024,11,5]],"date-time":"2024-11-05T16:29:38Z","timestamp":1730824178000},"page":"1-30","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":9,"title":["ZS4C: Zero-Shot Synthesis of Compilable Code for Incomplete Code Snippets Using LLMs"],"prefix":"10.1145","volume":"34","author":[{"ORCID":"https:\/\/orcid.org\/0009-0002-6077-7631","authenticated-orcid":false,"given":"Azmain","family":"Kabir","sequence":"first","affiliation":[{"name":"University of Manitoba, Winnipeg, Manitoba, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-3823-1771","authenticated-orcid":false,"given":"Shaowei","family":"Wang","sequence":"additional","affiliation":[{"name":"University of Manitoba, Winnipeg, Manitoba, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-2208-3893","authenticated-orcid":false,"given":"Yuan","family":"Tian","sequence":"additional","affiliation":[{"name":"Queen\u2019s University, Kingston, Ontario, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-4027-0905","authenticated-orcid":false,"given":"Tse-Hsun (Peter)","family":"Chen","sequence":"additional","affiliation":[{"name":"Concordia University, Montreal, Quebec, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-1420-105X","authenticated-orcid":false,"given":"Muhammad","family":"Asaduzzaman","sequence":"additional","affiliation":[{"name":"University of Windsor, Windsor, Ontario, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-3024-5415","authenticated-orcid":false,"given":"Wenbin","family":"Zhang","sequence":"additional","affiliation":[{"name":"Florida International University, Miami, FL, USA"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,4,28]]},"reference":[{"key":"e_1_3_2_2_2","unstructured":"ZS4C. 2023. Retrieved from https:\/\/anonymous.4open.science\/r\/ZS4C\/"},{"key":"e_1_3_2_3_2","doi-asserted-by":"crossref","unstructured":"Yejin Bang Samuel Cahyawijaya Nayeon Lee Wenliang Dai Dan Su Bryan Wilie Holy Lovenia Ziwei Ji Tiezheng Yu Willy Chung et al. 2023. A multitask multilingual multimodal evaluation of ChatGPT on reasoning hallucination and interactivity. arXiv:2302.04023. Retrieved from https:\/\/arxiv.org\/abs\/2302.04023","DOI":"10.18653\/v1\/2023.ijcnlp-main.45"},{"key":"e_1_3_2_4_2","first-page":"1877","volume-title":"Advances in Neural Information Processing Systems","volume":"33","author":"Brown Tom","year":"2020","unstructured":"Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D. Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. 2020. Language models are few-shot learners. In Advances in Neural Information Processing Systems, Vol. 33, 1877\u20131901."},{"key":"e_1_3_2_5_2","unstructured":"Mark Chen Jerry Tworek Heewoo Jun Qiming Yuan Henrique Ponde de Oliveira Pinto Jared Kaplan Harri Edwards Yuri Burda Nicholas Joseph Greg Brockman et al. 2021. Evaluating large language models trained on code. arXiv:2107.03374. Retrieved from https:\/\/arxiv.org\/abs\/2107.03374"},{"key":"e_1_3_2_6_2","unstructured":"Pyflakes Developers. 2024. Pyflakes: A simple program which checks Python source files for errors. Version 3.2.0. Retrieved from https:\/\/pypi.org\/project\/pyflakes\/"},{"key":"e_1_3_2_7_2","doi-asserted-by":"publisher","DOI":"10.1145\/3510003.3510061"},{"key":"e_1_3_2_8_2","doi-asserted-by":"crossref","unstructured":"Zhangyin Feng Daya Guo Duyu Tang Nan Duan Xiaocheng Feng Ming Gong Linjun Shou Bing Qin Ting Liu Daxin Jiang et al. 2020. Codebert: A pre-trained model for programming and natural languages. arXiv:2002.08155. Retrieved from https:\/\/arxiv.org\/abs\/2002.08155","DOI":"10.18653\/v1\/2020.findings-emnlp.139"},{"key":"e_1_3_2_9_2","unstructured":"Simon Frieder Luca Pinchetti Alexis Chevalier Ryan-Rhys Griffiths Tommaso Salvatori Thomas Lukasiewicz Philipp Christian Petersen and Julius Berner. 2023. Mathematical capabilities of ChatGPT. arXiv:2301.13867. Retrieved from https:\/\/arxiv.org\/abs\/2301.13867"},{"key":"e_1_3_2_10_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE.2015.81"},{"key":"e_1_3_2_11_2","first-page":"761","volume-title":"Proceedings of the 38th IEEE\/ACM International Conference on Automated Software Engineering (ASE \u201923)","author":"Gao Shuzheng","year":"2023","unstructured":"Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang, and Michael R. Lyu. 2023. Constructing effective in-context demonstration for code intelligence tasks: An empirical study. In Proceedings of the 38th IEEE\/ACM International Conference on Automated Software Engineering (ASE \u201923), 761\u2013773."},{"key":"e_1_3_2_12_2","doi-asserted-by":"publisher","DOI":"10.18653\/v1\/2021.acl-long.295"},{"key":"e_1_3_2_13_2","doi-asserted-by":"publisher","DOI":"10.1145\/3551349.3556912"},{"key":"e_1_3_2_14_2","unstructured":"JetBrains Community. 2018. Auto-complete does not always add the import statement. Retrieved 23 June 2024 from https:\/\/intellij-support.jetbrains.com\/hc\/en-us\/community\/posts\/360001093119-Auto-complete-does-not-always-add-the-import-statement"},{"key":"e_1_3_2_15_2","unstructured":"Patrick Lewis Ethan Perez Aleksandra Piktus Fabio Petroni Vladimir Karpukhin Naman Goyal Heinrich K\u00fcttler Mike Lewis Wen tau Yih Tim Rockt\u00e4schel et al. 2021. Retrieval-augmented generation for knowledge-intensive NLP tasks. arXiv:2005.11401. Retrieved from https:\/\/arxiv.org\/abs\/2005.11401"},{"key":"e_1_3_2_16_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00089"},{"issue":"943","key":"e_1_3_2_17_2","first-page":"21558","article-title":"Is your code generated by ChatGPT really correct? Rigorous evaluation of large language models for code generation","volume":"36","author":"Liu Jiawei","year":"2024","unstructured":"Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. 2024. Is your code generated by ChatGPT really correct? Rigorous evaluation of large language models for code generation. In Advances in Neural Information Processing Systems 36, 943 (2024), 21558\u201321572.","journal-title":"Advances in Neural Information Processing Systems"},{"key":"e_1_3_2_18_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00159"},{"key":"e_1_3_2_19_2","unstructured":"Zhijie Liu Yutian Tang Meiyun Li Xin Jin Yunfei Long Liang Feng Zhang and Xiapu Luo. 2024. LLM-CompDroid: Repairing configuration compatibility bugs in android apps with pre-trained large language models. arXiv:2402.15078. Retrieved from https:\/\/arxiv.org\/abs\/2402.15078"},{"key":"e_1_3_2_20_2","doi-asserted-by":"crossref","unstructured":"Yao Lu Max Bartolo Alastair Moore Sebastian Riedel and Pontus Stenetorp. 2021. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. arXiv:2104.08786. Retrieved from https:\/\/arxiv.org\/abs\/2104.08786","DOI":"10.18653\/v1\/2022.acl-long.556"},{"key":"e_1_3_2_21_2","unstructured":"Wei Ma Shangqing Liu Wenhan Wang Qiang Hu Ye Liu Cen Zhang Liming Nie and Yang Liu. 2023. LMs: Understanding code syntax and semantics for code analysis. arXiv:2305.12138. Retrieved from https:\/\/arxiv.org\/abs\/2305.12138"},{"key":"e_1_3_2_22_2","doi-asserted-by":"crossref","unstructured":"Sewon Min Xinxi Lyu Ari Holtzman Mikel Artetxe Mike Lewis Hannaneh Hajishirzi and Luke Zettlemoyer. 2022. Rethinking the role of demonstrations: What makes in-context learning work? arXiv:2202.12837. Retrieved from https:\/\/arxiv.org\/abs\/2202.12837","DOI":"10.18653\/v1\/2022.emnlp-main.759"},{"key":"e_1_3_2_23_2","doi-asserted-by":"publisher","DOI":"10.1145\/2384616.2384689"},{"key":"e_1_3_2_24_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE48619.2023.00205"},{"key":"e_1_3_2_25_2","unstructured":"Erik Nijkamp Bo Pang Hiroaki Hayashi Lifu Tu Huan Wang Yingbo Zhou Silvio Savarese and Caiming Xiong. 2022. Codegen: An open large language model for code with multi-turn program synthesis. arXiv:2203.13474. Retrieved from https:\/\/arxiv.org\/abs\/2203.13474"},{"key":"e_1_3_2_26_2","unstructured":"OpenAI. 2023. ChatGPT. Retrieved from https:\/\/chat.openai.com\/"},{"key":"e_1_3_2_27_2","unstructured":"OpenAI. 2023. gpt-3.5-turbo. Retrieved from https:\/\/platform.openai.com\/docs\/models\/gpt-3-5"},{"key":"e_1_3_2_28_2","unstructured":"OpenAI. 2023. gpt-4-turbo. Retrieved from https:\/\/platform.openai.com\/docs\/models\/gpt-4"},{"key":"e_1_3_2_29_2","doi-asserted-by":"publisher","DOI":"10.1145\/3597503.3639226"},{"key":"e_1_3_2_30_2","doi-asserted-by":"publisher","DOI":"10.1145\/3180155.3180230"},{"key":"e_1_3_2_31_2","unstructured":"Russell A. Poldrack Thomas Lu and Ga\u0161per Begu\u0161. 2023. AI-assisted coding: Experiments with GPT-4. arXiv:2304.13187. Retrieved from https:\/\/arxiv.org\/abs\/2304.13187"},{"key":"e_1_3_2_32_2","doi-asserted-by":"publisher","DOI":"10.1016\/j.infsof.2020.106367"},{"key":"e_1_3_2_33_2","doi-asserted-by":"publisher","DOI":"10.1145\/2786805.2786855"},{"key":"e_1_3_2_34_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE.2019.00032"},{"key":"e_1_3_2_35_2","unstructured":"Max Sch\u00e4fer Sarah Nadi Aryaz Eghbali and Frank Tip. 2023. An empirical evaluation of using large language models for automated unit test generation. arXiv:2302.06527. Retrieved from https:\/\/arxiv.org\/abs\/2302.06527"},{"key":"e_1_3_2_36_2","doi-asserted-by":"publisher","DOI":"10.1145\/2568225.2568313"},{"key":"e_1_3_2_37_2","first-page":"1","article-title":"Use Chat GPT to solve programming bugs","author":"Surameery Nigar M. Shafiq","year":"2023","unstructured":"Nigar M. Shafiq Surameery and Mohammed Y. Shakor. 2023. Use Chat GPT to solve programming bugs. International Journal of Information Technology & Computer Engineering, 1 (2023), 17\u201322.","journal-title":"International Journal of Information Technology & Computer Engineering"},{"key":"e_1_3_2_38_2","unstructured":"Great Learning Team. 2024. Top 30 Python libraries to know. Retrieved from https:\/\/www.mygreatlearning.com\/blog\/open-source-python-libraries\/"},{"key":"e_1_3_2_39_2","doi-asserted-by":"publisher","DOI":"10.1145\/2931037.2931058"},{"key":"e_1_3_2_40_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE51524.2021.9678576"},{"key":"e_1_3_2_41_2","doi-asserted-by":"publisher","DOI":"10.1109\/WAIN52551.2021.00011"},{"key":"e_1_3_2_42_2","unstructured":"Xuezhi Wang Jason Wei Dale Schuurmans Quoc Le Ed Chi and Denny Zhou. 2022. Self-consistency improves chain of thought reasoning in language models. arXiv:2203.11171. Retrieved from https:\/\/arxiv.org\/abs\/2203.11171"},{"key":"e_1_3_2_43_2","doi-asserted-by":"crossref","unstructured":"Yue Wang Weishi Wang Shafiq Joty and Steven C. H. Hoi. 2021. Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. arXiv:2109.00859. Retrieved from https:\/\/arxiv.org\/abs\/2109.00859","DOI":"10.18653\/v1\/2021.emnlp-main.685"},{"key":"e_1_3_2_44_2","doi-asserted-by":"crossref","unstructured":"Albert Webson and Ellie Pavlick. 2021. Do prompt-based models really understand the meaning of their prompts? In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies 2300\u20132344. Retrieved from https:\/\/aclanthology.org\/2022.naacl-main.167","DOI":"10.18653\/v1\/2022.naacl-main.167"},{"key":"e_1_3_2_45_2","doi-asserted-by":"publisher","unstructured":"Yuxiang Wei Chunqiu Steven Xia and Lingming Zhang. 2023. Copiloting the copilots: Fusing large language models with completion engines for automated program repair. In Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering 172\u2013184. Retrieved from 10.1145\/3611643.3616271","DOI":"10.1145\/3611643.3616271"},{"key":"e_1_3_2_46_2","unstructured":"Jules White Quchen Fu Sam Hays Michael Sandborn Carlos Olea Henry Gilbert Ashraf Elnashar Jesse Spencer-Smith and Douglas C. Schmidt. 2023. A prompt pattern catalog to enhance prompt engineering with ChatGPT. arXiv:2302.11382. Retrieved from https:\/\/arxiv.org\/abs\/2302.11382"},{"key":"e_1_3_2_47_2","unstructured":"Qingyun Wu Gagan Bansal Jieyu Zhang Yiran Wu Shaokun Zhang Erkang Zhu Beibin Li Li Jiang Xiaoyun Zhang and Chi Wang. 2023. AutoGen: Enabling next-gen LLM applications via multi-agent conversation framework. arXiv:2308.08155. Retrieved from https:\/\/arxiv.org\/abs\/2308.08155"},{"key":"e_1_3_2_48_2","doi-asserted-by":"publisher","DOI":"10.1007\/s10664-018-9634-5"},{"key":"e_1_3_2_49_2","unstructured":"Zhiheng Xi Wenxiang Chen Xin Guo Wei He Yiwen Ding Boyang Hong Ming Zhang Junzhe Wang Senjie Jin Enyu Zhou et al. 2023. The rise and potential of large language model based agents: A survey. arXiv:2309.07864. Retrieved from https:\/\/arxiv.org\/abs\/2309.07864"},{"key":"e_1_3_2_50_2","unstructured":"Chunqiu Steven Xia and Lingming Zhang. 2023. Conversational automated program repair. arXiv:2301.13246. Retrieved from https:\/\/arxiv.org\/abs\/2301.13246"},{"key":"e_1_3_2_51_2","doi-asserted-by":"publisher","DOI":"10.1007\/s10664-017-9514-4"},{"key":"e_1_3_2_52_2","unstructured":"Zhuokui Xie Yinghao Chen Chen Zhi Shuiguang Deng and Jianwei Yin. 2023. ChatUniTest: A ChatGPT-based automated unit test generation tool. arXiv:2305.04764. Retrieved from https:\/\/arxiv.org\/abs\/2305.04764"},{"key":"e_1_3_2_53_2","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2021.3058985"},{"key":"e_1_3_2_54_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2019.00046"},{"key":"e_1_3_2_55_2","unstructured":"Yuwei Zhang Zhi Jin Ying Xing and Ge Li. 2023. STEAM: Simulating the interactive behavior of programmers for automatic bug fixing. arXiv:2308.14460. Retrieved from https:\/\/arxiv.org\/abs\/2308.14460"},{"key":"e_1_3_2_56_2","volume-title":"Proceedings of the 11th International Conference on Learning Representations","author":"Zhou Shuyan","year":"2022","unstructured":"Shuyan Zhou, Uri Alon, Frank F. Xu, Zhengbao Jiang, and Graham Neubig. 2022. Docprompting: Generating code by retrieving the docs. In Proceedings of the 11th International Conference on Learning Representations. Retrieved from https:\/\/arxiv.org\/abs\/2207.05987"},{"key":"e_1_3_2_57_2","unstructured":"Yongchao Zhou Andrei Ioan Muresanu Ziwen Han Keiran Paster Silviu Pitis Harris Chan and Jimmy Ba. 2022. Large language models are human-level prompt engineers. arXiv:2211.01910. Retrieved from https:\/\/arxiv.org\/abs\/2211.01910"}],"container-title":["ACM Transactions on Software Engineering and Methodology"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3702979","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3702979","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,19]],"date-time":"2025-06-19T01:18:04Z","timestamp":1750295884000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3702979"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,4,28]]},"references-count":56,"journal-issue":{"issue":"4","published-print":{"date-parts":[[2025,5,31]]}},"alternative-id":["10.1145\/3702979"],"URL":"https:\/\/doi.org\/10.1145\/3702979","relation":{},"ISSN":["1049-331X","1557-7392"],"issn-type":[{"value":"1049-331X","type":"print"},{"value":"1557-7392","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,4,28]]},"assertion":[{"value":"2024-01-21","order":0,"name":"received","label":"Received","group":{"name":"publication_history","label":"Publication History"}},{"value":"2024-10-05","order":2,"name":"accepted","label":"Accepted","group":{"name":"publication_history","label":"Publication History"}},{"value":"2025-04-28","order":3,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}