Appearance
Go named types on the proved path
Status: accepted · Date: 2026-11-26
The proved path now reads a type that a package declares over a predeclared type, such as type Celsius int, type Open bool, type Name string or the alias type Count = int64, and conversions to such a type. This record says how the interpreter, the translator and the proof treat them.
The decision
- The interpreter.
Eval.Programholds each such type with the name of its underlying type. The zero value of the type is that of its underlying type ("The zero value"). A call of the type's name is a conversion ("Conversions"). It keeps the value, because every value of the subset has the same representation in a type and in its underlying type. The interpreter has no rule for an integer converted to a string type, which gives a code point, so it gives no result there. - The translator. A named type is its underlying type. The output types a parameter
c CelsiusasIntand writesCelsius(x)asx. The string translation still writesabbrev Celsius := Intfor the rest of the file. - Type checking stays with Go. The translator does not keep
Celsiusapart fromint. It would acceptc + xfor aCelsiuscand anintx, whichgo buildrefuses. The proof needs no such check, because the interpreter has no types: the output computes what the interpreter does for every program, typed or not. The CLI's input is a package that compiles, and the differential test compiles each program withgo run. - Conversions to a string type stay off the proved path. Go allows
Name(65)and gives"A". The proof has no type invariant on values that would show an operand of typestringis a string, so the translator refuses every conversion to a type overstring. Locals, parameters and constants of such a type are fine, because they need no conversion. - Other conversions. The subset converts an integer to a type over
intorint64, as it already did forint(x)andint64(x), and a bool to a type overbool. - Left out: a type over another type of the package, as in
type Temp Celsius, which needs the chain of underlying types; a type over a composite type, which waits for structs; and methods.
This page is docs/decisions/2026-11-26-go-named-types.md at commit 5f1d031.
