Documentation
¶
Overview ¶
Package types contains target-independent semantic types.
Index ¶
- Constants
- func Assignable(target, value Type) bool
- func Equivalent(left, right Type) bool
- func FunctionSignature(function Type) ([]Type, Type, bool)
- func IsIntegerLiteralSource(source string) bool
- func IsLiteral(typ Type) bool
- func ParsePortableFloatLiteral(source string) (float64, bool)
- func ParsePortableIntegerLiteral(source string) (int64, bool)
- type Kind
- type Type
- func CommonType(left, right Type) (Type, bool)
- func FromName(name string) Type
- func FunctionOf(parameters []Type, result Type) Type
- func LiteralBase(typ Type) (Type, bool)
- func LiteralFromSource(source string) (Type, bool)
- func LiteralUnionBase(typ Type) (Type, bool)
- func UnionOf(input ...Type) Type
Constants ¶
const ( MinPortableInteger int64 = -9007199254740991 MaxPortableInteger int64 = 9007199254740991 )
Variables ¶
This section is empty.
Functions ¶
func Assignable ¶
func Equivalent ¶
Equivalent compares semantic types while ignoring binding-level readonly state. Mutable generic containers use it to avoid unsound argument widening.
func IsIntegerLiteralSource ¶ added in v0.3.8
func ParsePortableFloatLiteral ¶ added in v0.3.25
ParsePortableFloatLiteral accepts finite binary64 literals. Runtime Float arithmetic may produce infinities and NaN, but source literals never spell non-finite values directly. Underflow follows binary64 and rounds to zero.
func ParsePortableIntegerLiteral ¶ added in v0.3.8
Types ¶
type Kind ¶
type Kind string
const ( Invalid Kind = "invalid" // Never is the compiler-internal bottom type for expressions that cannot // produce a value because control leaves the current flow. Never Kind = "never" Any Kind = "any" Void Kind = "void" Bool Kind = "bool" Int Kind = "int" IntLiteral Kind = "int_literal" Float Kind = "float" String Kind = "string" StringLiteral Kind = "string_literal" Bytes Kind = "bytes" StringBuilder Kind = "string_builder" Array Kind = "array" Range Kind = "range" Iterable Kind = "iterable" Hash Kind = "hash" Function Kind = "function" Union Kind = "union" Named Kind = "named" Nil Kind = "nil" )
type Type ¶
func CommonType ¶ added in v0.1.8
CommonType returns the most-specific type that can represent both inputs through portable implicit conversions. It deliberately does not fall back to Any: callers choose whether a missing common type is an error, a union, or a dynamic boundary.
func FunctionOf ¶ added in v0.2.3
func LiteralBase ¶ added in v0.2.3
func LiteralFromSource ¶ added in v0.2.3
LiteralFromSource returns the compile-time type denoted by an explicit Integer or String literal in a type position. Literal types are erased to their ordinary scalar representation by non-TypeScript backends.