Skip to content

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 type Name over string only when it types e as string. The output is the IR operation asString, which evaluates to its operand on a string and prints as the operand alone. The interpreter's convert rule keeps a string; the proof follows the len case: the IR evaluation of asString succeeds 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.declTypes now reads every type definition or alias whose type is a name and follows the chain with underlying to 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 as type A B; type B A gives 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.