Optional structured companion data on a TypeDiagnostic. The
variants map one-to-one with diagnostics that have specific
tooling-consumable state beyond the human-readable message; each
variant is attached only by the sites that produce its
corresponding diagnostic, so a consumer can pattern-match on the
variant without parsing the error string.
If types is exactly two members and one is nil, return the
non-nil member when it can be safely rendered as T?. Mirrors the
formatter’s rule in harn-fmt::helpers::optional_sugar_inner: only
types that appear at primary precedence (or below) can be sugared,
because postfix ? parses tighter than & / | / fn(...) -> ...
return positions.
The non-nil arm of a T | nil union that may render as the sugared T?.
Produce a detail string describing why a Shape type is incompatible with
another Shape type — e.g. “missing field ‘age’ (int)” or “field ‘name’
has type int, expected string”. Returns None if both types are not shapes.
Substitute generic bindings with the same open-row folding used by type
inference. Schema compilation calls this instead of carrying a second type
expression rewriter.