Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code

Hugging Face Daily Papers Papers

Summary

This paper introduces generative compilation, a method to obtain compiler feedback on partial programs during AI code generation, using a 'sealor' transformation that enables standard compilers to diagnose incomplete code. Evaluated on Rust coding tasks, it reduces non-compiling outputs and improves functional correctness by catching errors early.

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.
Original Article
View Cached Full Text

Cached at: 07/16/26, 09:45 PM

Paper page - Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code

Source: https://huggingface.co/papers/2607.13921 Published on Jul 15

·

Submitted byhttps://huggingface.co/nmuendler

Nielson Jul 16

Abstract

Languageswithrichstaticsemantics,suchasRust,providestrongerguaranteesforAI-generatedcode,buttheirstrictnessmakesgenerationmoredifficult.Off-the-shelfcompilerscanprovideusefulfeedbackpost-generation,butdoesnotguideintermediategenerationsteps,suchasthoseduringautoregressiveLLMdecoding.Constraineddecodingintervenesearlierbyrejectinginvalidtokensduringsampling,butrequireswhite-boxmodelaccessandcostlyreimplementationforsemanticconstraints.Weintroducegenerativecompilation,thefirstapproachtoobtainingcompilerfeedbackonpartialprogramsduringgeneration.Thecoretechnicaldeviceisasealor:alightweight,mostlysyntax-guidedtransformationthatconvertspartialprogramsintocompleteonesthatstandardcompilerscandiagnose.Itisdesignedsuchthatpossible-to-completepartialprogramsareneverrejected,whilepreservingenoughcodecontexttocatchgenuinedeadendsearly.WeconstructsuchasealoronacoreRust-likecalculusandprovethatitsatisfiestheseproperties,allmechanizedinLean.Weextendittothefirstpartial-programcheckerforrealRust.Weevaluateourmethodonchallengingrepository-levelRustcodingtasks,acrossbothfrontierblack-boxandopen-weightmodels.Weshowthatgenerativecompilationreducesnon-compilingoutputsandimprovesfunctionalcorrectness,relativetostandardpost-generationfeedback.Itdoessobydetectingabroadrangeoferrorsclosetotheirsourceandearlyduringgeneration,therebyreducingerrorscascadesandenablingfocuseddiagnostics.Morebroadly,generativecompilationisasteptowardmakingcompilersafirst-classcitizenofAI-assistedprogrammingactiveduringgeneration,ratherthanaseparatepost-generationcheck.

View arXiv pageView PDFGitHubAdd to collection

Models citing this paper0

No model linking this paper

Cite arxiv.org/abs/2607.13921 in a model README.md to link it from this page.

Datasets citing this paper2

#### eth-sri/CRUST-bench Viewer• Updated28 minutes ago • 117 #### eth-sri/API-Upgrade Viewer• Updated28 minutes ago • 34

Spaces citing this paper0

No Space linking this paper

Cite arxiv.org/abs/2607.13921 in a Space README.md to link it from this page.

Collections including this paper1

Similar Articles

AI Generated Code Quality

Reddit r/AI_Agents

The article discusses concerns that as AI tools generate increasing amounts of code, future models trained on this synthetic code may suffer from reduced quality and originality, and asks how major AI labs like OpenAI, Anthropic, and GitHub plan to address this issue.

Using AI to write better code more slowly

Lobsters Hottest

Nolan Lawson argues that AI coding assistants can be used to write high-quality code slowly by employing multiple models for thorough code review and bug detection, improving codebase health rather than maximizing output speed.