Appearance
Go named types: string conversions and chains
Status: accepted · Date: 2026-12-05
Follows Go named types on the proved path, which left out conversions to a type over string and types over other types of the package.
The decision
- Conversions to a string type. The translator accepts
Name(e)for a typeNameoverstringonly when it typeseasstring. The output is the IR operationasString, which evaluates to its operand on a string and prints as the operand alone. The interpreter'sconvertrule keeps a string; the proof follows thelencase: the IR evaluation ofasStringsucceeds only on a string, so the operand's value is a string and both sides agree. An integer operand, which Go turns into a code point, stays refused, as the interpreter has no rule for it. - Chains of types.
Eval.declTypesnow reads every type definition or alias whose type is a name and follows the chain withunderlyingto a predeclared type that the package does not declare, as the Go specification's "Underlying types" does. The fuel is the number of such declarations, so a cycle such astype A B; type B Agives no underlying type and leaves the subset; Go refuses it too. Declaration order does not matter. - Still left out: a type over a composite type, such as an array or a struct (
type Q P), which needs arrays or a struct under a second name; methods on a named type of a basic type.
This page is docs/decisions/2026-12-05-go-named-type-chains.md at commit 5f1d031.
