Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code
Not on the map. Why?
Abstract (arXiv)
Languages with rich static semantics, such as Rust, provide stronger guarantees for AI-generated code, but their strictness makes generation more difficult. Off-the-shelf compilers can provide useful feedback post-generation, but does not guide intermediate generation steps, such as those during autoregressive LLM decoding. Constrained decoding intervenes earlier by rejecting invalid tokens during sampling, but requires white-box model access and costly reimplementation for semantic constraints. We introduce generative compilation, the first approach to obtaining compiler feedback on partial programs during generation. The core technical device is a sealor: a lightweight, mostly syntax-guided transformation that converts partial programs into complete ones that standard compilers can diagnose. It is designed such that possible-to-complete partial programs are never rejected, while preserving enough code context to catch genuine dead ends early. We construct such a sealor on a core Rust-like calculus and prove that it satisfies these properties, all mechanized in Lean. We extend it to the first partial-program checker for real Rust. We evaluate our method on challenging repository-level Rust coding tasks, across both frontier black-box and open-weight models. We show that generative compilation reduces non-compiling outputs and improves functional correctness, relative to standard post-generation feedback. It does so by detecting a broad range of errors close to their source and early during generation, thereby reducing errors cascades and enabling focused diagnostics. More broadly, generative compilation is a step toward making compilers a first-class citizen of AI-assisted programming active during generation, rather than a separate post-generation check.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 28 of its 58 references that are in the map. First posted on arXiv 15 Jul 2026.
Builds on
28 of 58 references.
References · 28
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
- 2024A Survey on Large Language Models for Code Generationcited by 646
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2025Context Length Alone Hurts LLM Performance Despite Perfect Retrievalcited by 118
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 99
- 2024Grammar-Aligned Decodingcited by 54
- 2022Compilable Neural Code Generation with Compiler Feedbackcited by 46
- 2024Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedbackcited by 45
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 38
- 2025Type-Constrained Code Generation with Language Modelscited by 32
- 2024IterGen: Iterative Semantic-aware Structured LLM Generation with Backtrackingcited by 28
16 more
- 2015Program Synthesis from Polymorphic Refinement Typescited by 20
- 2025Fast Controlled Generation from Language Models with Adaptive Weighted Rejection Samplingcited by 20
- 2025CRUST-Bench: A Comprehensive Benchmark for C-to-safe-Rust Transpilationcited by 19
- 2025Constrained Sampling for Language Models Should Be Easy: An MCMC Perspectivecited by 14
- 2025ChopChop: a Programmable Framework for Semantically Constraining the Output of Language Modelscited by 12
- 2024Statically Contextualizing Large Language Models with Typed Holescited by 9
- 2016Hazelnut: A Bidirectionally Typed Structure Editor Calculuscited by 8
- 2024Constrained Decoding for Fill-in-the-Middle Code Language Models via Efficient Left and Right Quotienting of Context-Sensitive Grammarscited by 8
- 2018Live Functional Programming with Typed Holescited by 7
- 2022Aeneas: Rust Verification by Functional Translationcited by 7
- 2026Evaluating and Improving Automated Repository-Level Rust Issue Resolution with LLM-based Agentscited by 7
- 2020RustHorn: CHC-based Verification for Rust Programs (full version)cited by 5
- 2025TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generationcited by 5
- 2017Learning to Blame: Localizing Novice Type Errors with Data-Driven Diagnosiscited by 2
- 2019Oxide: The Essence of Rustcited by 2
- 2026Type-Error Ablation and AI Coding Agentscited by 2
Built on by
Not cited yet.