Welterweight Go: Boxing, Structural Subtyping, and Generics
Raymond Hu, Julien Lange, Bernardo Toninho, Philip Wadler, Robert Griesemer, Keith Randall
Abstract
Go's unique combination of structural subtyping between generics and types with non-uniform runtime representations presents significant challenges for formalising the language.
We introduce WG (Welterweight Go), a core model of Go that captures key features excluded by prior work, including underlying types, type unions and type sets, and proposed new features, such as generic methods. We also develop LWG, a lower-level language that models Go's runtime mechanisms, notably the distinction between raw struct values and interface values that carry runtime type information (RTTI).
We give a type-directed compilation from WG to LWG that demonstrates how the proposed features can be implemented while observing important design and implementation goals for Go: compatibility with separate compilation, and no runtime code generation. Unlike existing approaches based on static monomorphisation, our compilation strategy uses runtime type conversions and adaptor methods to handle the complex interactions between structural subtyping, generics, and Go's runtime infrastructure.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
Lineage
Builds on2
Related papers
- Beyond Nominality: Faster Rapid Type Analysis in the Presence of Structural SubtypingElton Pinto, Milind ChabbiOOPSLA 2026
- Implementing Set-Theoretic TypesMickaël Laurent, Kim NguyễnOOPSLA 2026 · 1 citation
- Automated Verification of Go Programs via Bounded Model CheckingNicolas Dilley, Julien LangeASE 2021 · 21 citations
- A Formal Account of the Wasm 3.0 Concurrency ModelAzalea Raad, Michalis Kokologiannakis, Viktor Vafeiadis, Conrad WattOOPSLA 2026
- Code Translation with Compiler RepresentationsMarc Szafraniec, Baptiste Rozière, Hugh Leather, Patrick Labatut et al.ICLR 2023 · 18 citations
