v3.types #
Type aliases type values used by types.
Constants #
const bool_ = Primitive{
props: .boolean
}
const int_ = Primitive{
props: .integer
}
const i8_ = Primitive{
props: .integer
size: 8
}
const i16_ = Primitive{
props: .integer
size: 16
}
const i32_ = Primitive{
props: .integer
size: 32
}
const i64_ = Primitive{
props: .integer
size: 64
}
const u8_ = Primitive{
props: .integer | .unsigned
size: 8
}
const u16_ = Primitive{
props: .integer | .unsigned
size: 16
}
const u32_ = Primitive{
props: .integer | .unsigned
size: 32
}
const u64_ = Primitive{
props: .integer | .unsigned
size: 64
}
const f32_ = Primitive{
props: .float
size: 32
}
const f64_ = Primitive{
props: .float
size: 64
}
const string_ = String{}
const char_ = Char{}
const rune_ = Rune{}
const isize_ = ISize{}
const usize_ = USize{}
const void_ = Void{}
const nil_ = Nil{}
const none_ = None{}
const voidptr_ = Pointer{
base_type: Type(Void{})
}
const charptr_ = Pointer{
base_type: Type(Char{})
}
const byteptr_ = Pointer{
base_type: Type(Primitive{
props: .integer | .unsigned
size: 8
})
}
fn builtin_type #
fn builtin_type(name string) ?Type
builtin_type returns the Type for a builtin type name, or none otherwise.
fn builtin_type_value #
fn builtin_type_value(name string) Type
builtin_type_value returns the Type for a known builtin type name.
fn clone_owned_type #
fn clone_owned_type(value Type) Type
clone_owned_type clones a type and all nested owned metadata.
fn clone_owned_types #
fn clone_owned_types(values []Type) []Type
clone_owned_types clones a list of types and all nested owned metadata.
fn defer_result_index #
fn defer_result_index(node flat.Node) ?int
defer_result_index returns -1 for an unindexed $res() node and the non-negative index for a $res(index) node.
fn extend_stable_type_indexes #
fn extend_stable_type_indexes(mut indexes map[string]int, type_names []string)
extend_stable_type_indexes assigns deterministic, collision-free runtime indexes to new names without changing indexes that have already been used during lowering.
fn extend_stable_type_indexes_ref #
fn extend_stable_type_indexes_ref(mut indexes map[string]int, type_names &[]string)
extend_stable_type_indexes_ref is the pointer-ABI form used by native compiler stages.
fn generic_base_name #
fn generic_base_name(name string) string
generic_base_name returns the declaration part of a concrete generic type name.
fn is_builtin_type_name #
fn is_builtin_type_name(name string) bool
is_builtin_type_name reports whether name is one of V's builtin type names.
fn new_scope #
fn new_scope(parent &Scope) &Scope
new_scope returns a reusable type-checker scope with an optional parent.
fn stable_interface_type_ids #
fn stable_interface_type_ids(impl_names []string) map[string]int
stable_interface_type_ids assigns deterministic nonzero _typ dispatch IDs to interface implementers in caller-supplied order. Hash collisions are resolved with linear probing after earlier names keep their IDs, so late generic implementers appended after transform cannot shift IDs already emitted for existing interface values/checks.
fn stable_interface_type_ids_preserving_prefix #
fn stable_interface_type_ids_preserving_prefix(prefix []string, impl_names []string) map[string]int
stable_interface_type_ids_preserving_prefix assigns IDs for impl_names while keeping all prefix IDs exactly as they would be when assigned alone.
fn stable_type_index #
fn stable_type_index(name string) int
stable_type_index returns the deterministic nonzero runtime-index seed for a named type. Use stable_type_indexes when assigning indexes across a complete program type set.
fn stable_type_indexes #
fn stable_type_indexes(type_names []string) map[string]int
stable_type_indexes assigns deterministic, collision-free runtime indexes to the complete caller-supplied program type set.
fn type_text_contains_typeof #
fn type_text_contains_typeof(s string) bool
parse_type converts a V type string (from parser) to a structured Type. type_text_contains_typeof is a fast substring probe for typeof(: type texts are overwhelmingly short scalar/container names, so the length early-out plus a first-byte scan beats string.contains (KMP table build and call overhead) on hot paths that must screen every text.
fn unalias_type #
fn unalias_type(t Type) Type
unalias_type follows an alias chain to its underlying type, unwrapping each Alias to its base type until a non-alias type is reached and returned.
fn unsigned_shift_result_type #
fn unsigned_shift_result_type(t Type) Type
unsigned_shift_result_type returns the unsigned counterpart used as the result of >>>.
fn unwrap_all_pointers #
fn unwrap_all_pointers(t Type) Type
unwrap_all_pointers removes every pointer layer from t.
fn unwrap_pointer #
fn unwrap_pointer(t Type) Type
unwrap_pointer transforms unwrap pointer data for types.
fn Properties.from #
fn Properties.from[W](input W) !Properties
fn Properties.zero #
fn Properties.zero() Properties
fn ReceiverMutationVisibility.from #
fn ReceiverMutationVisibility.from[W](input W) !ReceiverMutationVisibility
fn RecursiveStrAggregateSlotKind.from #
fn RecursiveStrAggregateSlotKind.from[W](input W) !RecursiveStrAggregateSlotKind
fn RecursiveStrMutationEffect.from #
fn RecursiveStrMutationEffect.from[W](input W) !RecursiveStrMutationEffect
fn TypeChecker.new #
fn TypeChecker.new(a &flat.FlatAst) TypeChecker
new creates a TypeChecker value for types.
fn TypeErrorKind.from #
fn TypeErrorKind.from[W](input W) !TypeErrorKind
type SymbolId #
type SymbolId = u32
SymbolId is the stable identity of a resolved declaration name in one compilation. Zero denotes no symbol.
type Type #
type Type = Void
| Unknown
| Primitive
| String
| Char
| Rune
| ISize
| USize
| Nil
| None
| Array
| ArrayFixed
| Channel
| Map
| Pointer
| FnType
| OptionType
| ResultType
| Struct
| Interface
| Enum
| SumType
| Alias
| MultiReturn
fn (Type) is_pointer #
fn (t Type) is_pointer() bool
is_pointer reports whether is pointer applies in types.
fn (Type) is_string #
fn (t Type) is_string() bool
is_string reports whether is string applies in types.
fn (Type) is_integer #
fn (t Type) is_integer() bool
is_integer reports whether is integer applies in types.
fn (Type) is_float #
fn (t Type) is_float() bool
is_float reports whether is float applies in types.
fn (Type) name #
fn (t Type) name() string
name returns name data for Type.
type TypeId #
type TypeId = u32
TypeId is the stable identity of a canonical semantic type in one compilation. Type values remain the public compatibility representation; caches and equality-heavy internals can use this compact identity.
enum Properties #
enum Properties {
boolean
float
integer
unsigned
untyped
}
Properties lists properties values used by types.
fn (Properties) all #
fn (e &Properties) all(flag_ Properties) bool
fn (Properties) clear #
fn (mut e Properties) clear(flag_ Properties)
fn (Properties) clear_all #
fn (mut e Properties) clear_all()
fn (Properties) has #
fn (e &Properties) has(flag_ Properties) bool
fn (Properties) is_empty #
fn (e &Properties) is_empty() bool
fn (Properties) set #
fn (mut e Properties) set(flag_ Properties)
fn (Properties) set_all #
fn (mut e Properties) set_all()
fn (Properties) toggle #
fn (mut e Properties) toggle(flag_ Properties)
enum TypeErrorKind #
enum TypeErrorKind {
unknown_ident
unknown_type
unknown_fn
unknown_field
cannot_index
if_branch_mismatch
assignment_mismatch
return_mismatch
call_arg_mismatch
condition_mismatch
duplicate_decl
unhandled_node
unsupported_generic
compile_error
}
TypeErrorKind lists type error kind values used by types.
struct Alias #
struct Alias {
pub:
name string
base_type Type
}
Alias represents alias data used by types.
struct Array #
struct Array {
pub:
elem_type Type
}
Array represents array data used by types.
struct ArrayFixed #
struct ArrayFixed {
pub:
elem_type Type
len int
len_expr string
}
ArrayFixed represents array fixed data used by types.
struct CallInfo #
struct CallInfo {
pub:
name string
params []Type
shared_params []bool
return_type Type
has_receiver bool
is_variadic bool
is_c_variadic bool
params_known bool
has_implicit_veb_ctx bool
arg_offset int
}
CallInfo stores call info metadata used by types.
struct Channel #
struct Channel {
pub:
elem_type Type
is_mut bool
}
Channel represents channel data used by types.
struct Char #
struct Char {
dummy_ u8
}
Char represents char data used by types.
struct Enum #
struct Enum {
pub:
name string
is_flag bool
}
Enum represents enum data used by types.
struct FnType #
struct FnType {
pub:
params []Type
params_mut []bool
return_type Type
}
FnType represents fn type data used by types.
struct ISize #
struct ISize {
dummy_ u8
}
ISize represents isize data used by types.
struct Interface #
struct Interface {
pub:
name string
}
Interface represents interface data used by types.
struct InterfaceImplIndex #
struct InterfaceImplIndex {
pub:
names []string
ids map[string]int
}
struct Map #
struct Map {
pub:
key_type Type
value_type Type
}
Map represents map data used by types.
struct MultiReturn #
struct MultiReturn {
pub:
types []Type
}
MultiReturn represents multi return data used by types.
struct Nil #
struct Nil {
dummy_ u8
}
Nil represents nil data used by types.
struct None #
struct None {
dummy_ u8
}
None represents none data used by types.
struct OptionType #
struct OptionType {
pub:
base_type Type
}
OptionType represents option type data used by types.
struct OwnershipDropEntry #
struct OwnershipDropEntry {
pub:
name string
type_name string
optional_wrapper bool
}
struct Pointer #
struct Pointer {
pub:
base_type Type
}
Pointer represents pointer data used by types.
struct Primitive #
struct Primitive {
pub:
props Properties
size u8
}
Primitive represents primitive data used by types.
struct QualifyNameCache #
struct QualifyNameCache {
pub mut:
module string
file string
resolution_type_mode bool
fingerprint int = -1
entries map[string]string
last_name string
last_value string
last_valid bool
}
qualify_name supports qualify name handling for TypeChecker. QualifyNameCache memoizes qualify_name per source and type-resolution context. Its table fingerprint invalidates entries while collection is still growing the declared-type tables; every checker fork gets its own instance.
struct ResultType #
struct ResultType {
pub:
base_type Type
}
ResultType represents result type data used by types.
struct Rune #
struct Rune {
dummy_ u8
}
Rune represents rune data used by types.
struct Scope #
struct Scope {
pub mut:
parent &Scope = unsafe { nil }
names []string
types []Type
name_indexes map[string]int
// name_mask is a conservative bloom filter over this scope's own binding
// names: a cleared bit proves the name is absent, letting chain walks skip
// the per-level map probe (most lookups walk many levels that do not bind
// the name at all). False positives only cost the probe they would have
// paid anyway.
name_mask u64
fast_lookup bool
fast_generation u32
fast_name_ptrs [32]voidptr
fast_name_lens [32]u16
fast_indexes [32]u32
fast_generations [32]u32
generations []int
storage_keys []string
next_generation int
lifetime int
}
Scope represents scope data used by types.
fn (Scope) reset #
fn (mut s Scope) reset(parent &Scope)
reset retargets a pooled scope, clearing its bindings while keeping the backing storage capacity so reuse does not reallocate. Without this clear a pooled scope's arrays accumulate every binding ever inserted across all generations, turning lookup/insert into an O(n) scan over dead entries.
fn (Scope) lookup #
fn (s &Scope) lookup(name string) ?Type
lookup returns the nearest visible type binding for name.
fn (Scope) lookup_owner #
fn (s &Scope) lookup_owner(name string) ?ScopeBindingOwner
lookup_owner returns the nearest scope that owns a visible binding for name.
fn (Scope) nearest_binding_owned_by #
fn (s &Scope) nearest_binding_owned_by(name string, owner ScopeBindingOwner) bool
nearest_binding_owned_by reports whether the nearest visible binding for name belongs to owner.
fn (Scope) insert #
fn (mut s Scope) insert(name string, typ Type)
insert records or updates a type binding in this scope.
fn (Scope) insert_with_owner #
fn (mut s Scope) insert_with_owner(name string, typ Type) ScopeBindingOwner
insert_with_owner records or updates a type binding and returns the exact binding identity now visible for name.
struct ScopeBindingOwner #
struct ScopeBindingOwner {
scope &Scope = unsafe { nil }
index int = -1
generation int
lifetime int
name string
storage_key string
}
fn (ScopeBindingOwner) storage_key #
fn (owner ScopeBindingOwner) storage_key() string
storage_key returns a stable key for this binding owner while its scope is live.
fn (ScopeBindingOwner) belongs_to_scope #
fn (owner ScopeBindingOwner) belongs_to_scope(scope &Scope) bool
belongs_to_scope reports whether this binding owner was declared directly in scope.
fn (ScopeBindingOwner) belongs_to_scope_chain_until #
fn (owner ScopeBindingOwner) belongs_to_scope_chain_until(scope &Scope, stop &Scope) bool
belongs_to_scope_chain_until reports whether this binding owner was declared between scope and stop, inclusive.
struct String #
struct String {
dummy_ u8
}
String represents string data used by types.
struct Struct #
struct Struct {
pub:
name string
}
Struct represents struct data used by types.
struct StructField #
struct StructField {
pub:
name string
typ Type
has_default bool
is_embed bool
is_mut bool
is_volatile bool
}
StructField represents struct field data used by types.
struct SumType #
struct SumType {
pub:
name string
}
SumType represents sum type data used by types.
struct TransformForkOverlay #
struct TransformForkOverlay {
pub mut:
resolved_call_names map[int]string
resolved_fn_values map[int]string
// Transform forks write overlay entries only for nodes appended after the
// fork. IDs below this boundary are guaranteed to live in the shared dense
// checker arrays, so reads can avoid probing two sparse maps per expression.
base_node_count int
}
TransformForkOverlay holds the call/fn-value resolutions a parallel-transform worker records for its transform-created (cloned) nodes. It lives on the heap (like TypeCache) so a worker's &TypeChecker fork can write through the pointer without mutating the shared node-indexed arrays; reads consult the overlay before those arrays, and merge_worker replays the entries into the master under the shifted node ids.
struct TypeCacheStats #
struct TypeCacheStats {
pub:
parse_hits i64
parse_misses i64
c_hits i64
c_misses i64
}
TypeCacheStats reports semantic cache effectiveness for compiler telemetry.
struct TypeChecker #
struct TypeChecker {
pub mut:
a &flat.FlatAst = unsafe { nil }
compiler_vroot string
verbose bool
raw_type_equality bool
fast_parse_recent bool
fast_type_text_refs bool
fast_c_type_recent bool
memo_call_info bool
method_suffix_prescreen bool
prefix_param_scan bool
building_v_fast bool
valid_diagnostic_fast bool
valid_resolution_fast bool
defer_fn_ancillary bool
fn_ancillary_registrations []FnAncillaryRegistration
fn_c_variadic_registrations []FnNamePairRegistration
fn_mut_receiver_registrations []FnNamePairRegistration
fn_ret_text_registrations []FnTextRegistration
visible_mutation_registrations []VisibleMutationRegistration
enable_globals bool
fn_ret_types map[string]Type
fn_param_types map[string][]Type
v_fn_semantic_names map[string]bool
c_fn_module_ret_types map[string]Type
c_fn_module_param_types map[string][]Type
c_fn_module_variadic map[string]bool
fn_shared_params map[string][]bool
mut_receiver_methods map[string]bool
source_no_body_fns map[string]bool
source_no_body_fn_suffixes map[string]bool
unsafe_fns map[string]bool
unsafe_c_fns map[string]bool
fn_ret_type_texts map[string]string // generic struct method key -> original return type text (e.g. `Box[T].clone` -> `Box[T]`)
fn_param_type_texts map[string][]string // generic struct method key -> original param type texts (receiver first)
fn_type_files map[string]string
fn_type_modules map[string]string
transform_signature_maps_shared bool
transform_signature_maps_changed bool
transform_signature_names_log []string
transform_struct_maps_shared bool
fn_generic_params map[string][]string
specialized_generic_fns map[string]bool
fn_variadic map[string]bool
c_variadic_fns map[string]bool
fn_implicit_veb_ctx map[string]bool
receiver_method_suffix_index map[string]string
structs map[string][]StructField
struct_modules map[string]string
struct_files map[string]string
soa_structs map[string]bool
// set of `${file}\x01${module}\x01${name}` keys for every source-level
// struct/type/interface/enum declaration, built once in `collect`. Replaces
// the former full-node scan in `source_declares_type_in_scope`, which was
// O(nodes) per call and dominated check/transform/cgen (called via qualify_name).
declared_type_scope_keys map[string]bool
concrete_type_scope_keys map[string]bool
struct_error_embeds_shadow_builtin map[string]bool
struct_generic_params map[string][]string // generic struct base name -> type-param names (e.g. Vec4 -> [T])
struct_implements map[string][]string
struct_shared_fields map[string]bool
struct_shared_element_fields map[string]bool
struct_field_c_abi_fns map[string]string
// concrete `Box[int].method` -> substituted CallInfo for a method *value* on a
// generic receiver. The open `Box[T].method` registration is gone by cgen time, so
// the checker stashes the resolved signature here for gen_method_value_closure.
generic_method_value_info map[string]CallInfo
params_structs map[string]bool
c_typedef_structs map[string]bool
unions map[string]bool
type_aliases map[string]string
type_alias_modules map[string]string
type_alias_generic_params map[string][]string // generic alias base name -> type-param names
type_alias_c_abi_fns map[string]string
recursive_alias_names map[string]bool
sum_types map[string][]string
sum_generic_params map[string][]string // generic sum type base name -> type-param names (e.g. Tree -> [T])
enum_names map[string]bool
enum_fields map[string][]string
flag_enums map[string]bool
interface_names map[string]bool
interface_generic_params map[string][]string
interface_fields map[string][]StructField
interface_embeds map[string][]string
interface_abstract_methods map[string][]string // iface -> abstract (declared) method names
interface_impl_name_snapshots map[string][]string
interface_impl_candidates_at_snapshot map[string]bool
interface_impl_candidates_at_index map[string]bool
interface_method_names_index map[string][]string
interface_abstract_index map[string][]string
interface_field_list_index map[string][]StructField
interface_impl_indexes map[string]&InterfaceImplIndex
interface_query_indexes_ready bool
c_globals map[string]Type
global_names map[string]bool
const_types map[string]Type
const_exprs map[string]flat.NodeId
const_modules map[string]string
const_files map[string]string
const_suffixes map[string]string // dot-suffix -> full const key (O(1) lookup; '' if ambiguous)
declaration_visibility map[string]DeclarationVisibility
checked_const_names map[string]bool
imports map[string]string // alias -> short module name
file_imports map[string]string
file_selective_imports map[string][]string
file_imports_by_file map[string]&FileImportInfo
file_modules map[string]string
translated_files map[string]bool
has_globals_files map[string]bool
deprecated_symbols map[string]DeprecationInfo
file_scope &Scope = unsafe { nil }
cur_scope &Scope = unsafe { nil }
scope_pool []&Scope
scope_pool_index int
has_builtins bool
cur_module string
cur_file string
unsafe_depth int
lock_depth int
comptime_static_depth int
errors []TypeError
notices []TypeError
resolved_call_names []string // node_id -> resolved function name
resolved_call_set []bool
resolved_fn_value_names []string // node_id -> resolved function value name
resolved_fn_value_set []bool
statement_nodes []bool
// Exact call/function-value dependencies recorded while each function is
// checked. Consumers such as markused can walk these resolved Symbol-like
// names instead of reconstructing import and receiver resolution from syntax.
direct_dependencies_by_fn map[int][]SymbolId // enclosing fn node id -> resolved function identities
// Methods used as *values* (`recv.method` passed as a callback), recorded per enclosing
// function during semantic checking — which has full scope/type info, runs before
// markused, and (unlike a call) routes a value-context selector through check_selector.
// markused seeds these (keeping the wrapper-only method out of the dead-code pruner)
// only when their enclosing function is reachable.
method_values_by_fn map[int][]string // enclosing fn node id -> method-value `Type.method` keys
// Local variables bound to a method value (`cb := c.report`) in the current function.
// Escape checks use these aliases to retain the lifetime hazard of mutable methods
// borrowing addressable stack receivers. Reset per function.
method_value_locals map[string]bool
// Scope depth at which each method-value local was marked, so a reassignment to a
// non-method value only clears the marker when it dominates later uses (same-or-shallower
// scope); a reassignment in a deeper conditional/loop scope keeps the maybe-method marker.
method_value_local_depth map[string]int
capturing_fn_literal_locals map[string]bool
capturing_fn_literal_local_depth map[string]int
capturing_fn_literal_return_unsupported map[string]bool
cur_fn_node_id int = -1
cur_fn_mut_param_base_types map[string]Type
cur_fn_mut_param_binding_owners map[string]ScopeBindingOwner
cur_fn_mut_local_binding_owners map[string]ScopeBindingOwner
cur_fn_shared_binding_owners map[string]ScopeBindingOwner
cur_comptime_variant_loop_vars []string
expr_type_values []Type // node_id -> complex/contextual resolved type
expr_type_set []bool
lexical_smartcast_misses []bool
checking_nodes []bool
parallel_check_sparse bool
scope_parallel_check_workers bool
// Node id range [check_range_lo, check_range_hi] of the fn item currently
// being checked. Fn subtrees are disjoint contiguous ranges (each fn_decl at
// index i owns (prev_top_level_idx, i]), so while parallel_check_sparse is
// set, cache entries for in-range ids are written straight into the shared
// node-indexed arrays (this checker is the range's only writer) and only
// out-of-range ids (consts, other decls' nodes) go through the private
// sparse maps that are merged after join.
check_range_lo int = -1
check_range_hi int = -1
sparse_resolved_call_names map[int]string
sparse_resolved_fn_values map[int]string
sparse_statement_nodes map[int]bool
sparse_expr_type_values map[int]Type
sparse_checking_nodes map[int]bool
diagnose_unknown_calls bool
reject_unlowered_map_mutation bool
reject_unsupported_generics bool
checker_fixture_mode bool
autofree_mode bool
no_main bool
warns_are_errors bool
notes_are_errors bool
is_prod bool
suppress_dump_output bool
diagnostic_files map[string]bool
multiple_module_import_lines map[u64]bool
source_texts_by_file map[string]string
ct_update_pos map[int]token.Pos
ct_update_indexed bool
insert_include_dirs_by_file map[string][]string
has_spawn_expr int = -1
inactive_top_level_node_ids []int
selected_file_called_fns map[string]bool
// Names newly inserted into selected_file_called_fns and not yet chased by
// the transitive closure in collect_selected_file_called_fns_transitively.
selected_file_worklist []string
// During a scoped check, sites that would gate on the called-fns closure park
// their candidate error here. Successful builds skip the closure entirely;
// the master computes it after checking only when a candidate needs filtering.
defer_ierror_gating bool
pending_ierror_errors []PendingIerrorError
// Node indices of every top-level declaration node (file markers, module/import
// decls, type-level decls, consts, globals, fn/c-fn decls), in AST order. These
// kinds only occur at the top level, so a pass iterating this index visits the
// same nodes in the same order as a full `a.nodes` scan that matches on them —
// without streaming the ~100x larger node array each time. Built once in
// `collect`; no later phase of the check step appends declarations. Phases
// after the check (transform) may grow the AST: top_level_idx_nodes_len
// records the node count the index covers.
top_level_idx []int
top_level_idx_nodes_len int
// Anonymous and function-local struct declarations are synthesized below
// the file's top-level declaration tree. The direct-parent pass records their
// sorted node ids so collect_top_level_idx_fast can merge them without
// rescanning every gap between parser-recorded declarations.
synthetic_top_level_type_ids []int
expected_expr_id int = -1
expected_expr_type Type = Type(void_)
cur_fn_ret_type Type = Type(void_)
channel_send_or_expr_id int = -1
smartcasts map[string]Type
ownership &OwnershipState = unsafe { nil }
ownership_return_item_by_name map[string]int
ownership_return_edges []u64
ownership_return_current_item int = -1
ownership_return_record_calls bool
ownership_return_item_changed bool
ownership_param_item_by_name map[string]int
ownership_param_changed_items []bool
ownership_param_current_item int = -1
ownership_param_track_changes bool
// See QualifyNameCache: nil unless armed for a phase whose allocations
// outlive every prealloc scope arena; forks must replace it with their own
// instance. A long-lived armed cache written during a scoped driver stage
// (markused/transform/cgen under -prealloc) stores map buckets and result
// strings in the disposable scope arena, and later reads crash.
qualify_name_cache &QualifyNameCache = unsafe { nil }
// Per-fork resolve_type memo for the current check work item's node range;
// nil until check_fn_items_serial arms it (see BodyResolveMemo).
body_resolve_memo &BodyResolveMemo = unsafe { nil }
import_info_cache &ImportInfoCache = unsafe { nil }
// Nanoseconds spent in the ownership checker's per-fn boundary passes.
// Only `-d ownership` builds ever write it (every writer lives in
// checker_ownership_d_ownership.v), so plain builds report exactly 0.
ownership_time_ns i64
selfhost bool
// resolution_type_mode is enabled only after semantic checking, while transform
// and codegen read synthesized generic-specialization type text. Source annotations
// must keep normal module scoping and never enable this fallback.
resolution_type_mode bool
// trust_checked_expr_types serves resolve_type straight from the checker's
// dense per-node type cache. Armed by the driver only after checking
// completes; transform's node-write helpers invalidate rewritten ids, and
// nodes appended after checking fall outside the cache and resolve normally.
trust_checked_expr_types bool
// fork_overlay is non-nil only on parallel-transform worker forks; see
// TransformForkOverlay and fork_for_parallel_transform.
fork_overlay &TransformForkOverlay = unsafe { nil }
mut:
// Includes method-value aliases and binding-owner maps; all backing maps are
// replaced together at every function/worker boundary.
fn_context FunctionCheckContext
type_cache &TypeCache = unsafe { nil }
pre_transform_type_cache &TypeCache = unsafe { nil }
resolution_type_views &ResolutionTypeViewCache = unsafe { nil }
visible_mutation_cache &VisibleMutationCache = unsafe { nil }
type_interner &TypeInterner = unsafe { nil }
symbols &SymbolInterner = unsafe { nil }
// direct_parent_ids maps a parsed node to the first AST node that references
// it as a child. It is immutable during semantic checking and shared by
// checker workers. Transformed or appended nodes use the scan fallback in
// direct_parent_id.
direct_parent_ids []flat.NodeId
rewritten_parent_ids []flat.NodeId
value_used_nodes []bool
fn_check_costs []int
direct_parent_index_trusted bool
has_goto_nodes bool
// Immutable declaration indexes shared by checker workers.
declaration_attributes map[int][]string
type_declaration_ids map[string][]int
strings_builder_bindings map[string]bool
strings_builder_candidates []int
static_associated_fn_keys map[string]bool
declaration_param_mutability map[string][]bool
strict_map_index_files map[string]bool
// short fn name -> first declaring top-level node index, in declaration
// order (mirrors the expr_raw_fn_type_text scan's first-match rule).
fn_decl_short_name_ids map[string]int
// '${file}\x00${alias}' -> dotted import path, and '${file}\x00${last
// segment}' -> dotted import path (first import wins), replacing per-call
// scans over every top-level declaration.
file_import_alias_paths map[string]string
file_import_suffix_paths map[string]string
// struct name -> embedded receiver type names (empty entry when the struct
// has no embeds). Structs added after collect (monomorphization) miss this
// index and fall back to the field walk.
struct_embed_receivers map[string][]string
// Immutable node -> generic parameter index shared by checker workers.
enclosing_generic_params_by_node map[int][]string
enclosing_generic_param_masks []u32
}
TypeChecker represents type checker data used by types.
fn (TypeChecker) annotate_types #
fn (mut tc TypeChecker) annotate_types()
annotate_types performs a scope-aware walk over every function body, tracking local variable types as they are declared, and records complex/contextual expression types. This mirrors what the v2 transformer relies on: the type checker runs BEFORE the transformer and publishes per-expression types, so the transformer can own type-dependent lowering (string ops, in membership, ...) instead of the backend.
It uses a single flat scope per function (an over-approximation: a local stays visible after its block ends), which is harmless for type lookup since variable names are effectively unique within a function.
fn (TypeChecker) annotate_types_with_used #
fn (mut tc TypeChecker) annotate_types_with_used(used_fns map[string]bool)
annotate_types_with_used annotates only functions that can be emitted when used_fns is non-empty. This mirrors transform/cgen pruning and avoids resolving types in dead, untransformed function bodies after markused.
fn (TypeChecker) annotate_types_with_used_missing_calls #
fn (mut tc TypeChecker) annotate_types_with_used_missing_calls(used_fns map[string]bool, source_node_count int)
annotate_types_with_used_missing_calls revisits only reachable functions containing calls whose checked binding was invalidated by lowering, plus functions synthesized after the source AST. Unchanged calls retain the binding recorded by semantic checking and copied by the transformer.
fn (TypeChecker) arm_body_resolve_memo #
fn (tc &TypeChecker) arm_body_resolve_memo(lo int, hi int)
arm_body_resolve_memo (re)activates the per-item resolve memo for one work item's node range. The transformer arms it per lowered function exactly like the checker does per checked item; node-write helpers invalidate rewritten slots (see invalidate_checked_expr_type).
fn (TypeChecker) autofree_enabled #
fn (tc &TypeChecker) autofree_enabled() bool
autofree_enabled reports whether compatibility autofree lowering is active.
fn (TypeChecker) begin_sparse_transform_node_caches #
fn (mut tc TypeChecker) begin_sparse_transform_node_caches(base_nodes int)
begin_sparse_transform_node_caches keeps source-node entries in their dense checked arrays and records transform-created node metadata sparsely.
fn (TypeChecker) c_type #
fn (tc &TypeChecker) c_type(t Type) string
c_type supports c type handling for TypeChecker.
fn (TypeChecker) cached_c_name #
fn (tc &TypeChecker) cached_c_name(name string) string
cached_c_name memoizes naming.c_name results in the type cache (falling back to the frozen base cache read-only, like every other entry kind). c_name is pure and called on hot resolution paths in every phase.
fn (TypeChecker) canonical_qualified_type_name #
fn (tc &TypeChecker) canonical_qualified_type_name(name string) ?string
canonical_qualified_type_name resolves a possibly bare or partially qualified type name (e.g. PoolProcessor or pool.PoolProcessor) to its unique fully qualified spelling (sync.pool.PoolProcessor). It returns none when the name is unknown or when the short name is ambiguous across modules. Backends use this to rebuild method/type C names when a receiver type carries only the import-local module qualifier instead of the full module path.
fn (TypeChecker) canonical_symbol #
fn (tc &TypeChecker) canonical_symbol(name string) string
canonical_symbol returns the compilation-owned canonical spelling of name.
fn (TypeChecker) check_concrete_fn_semantics #
fn (mut tc TypeChecker) check_concrete_fn_semantics(fn_idx int, file string, module_name string)
check_concrete_fn_semantics validates a concrete generic function clone before the transformer lowers its body. The clone retains source positions, so errors use the normal checker renderer instead of positionless transform diagnostics.
fn (TypeChecker) check_interface_embedding_limits #
fn (mut tc TypeChecker) check_interface_embedding_limits() bool
check_interface_embedding_limits rejects deep interface casts before requirement indexes recursively expand the embedding chain.
fn (TypeChecker) check_main_module_requirement #
fn (mut tc TypeChecker) check_main_module_requirement(is_shared bool)
check_main_module_requirement rejects ordinary programs that contain no selected source file in the main module.
fn (TypeChecker) check_semantics #
fn (mut tc TypeChecker) check_semantics()
check_semantics validates check semantics state for types.
fn (TypeChecker) check_semantics_opt #
fn (mut tc TypeChecker) check_semantics_opt(want_parallel bool) bool
check_semantics_opt runs semantic checks, using worker threads for independent function bodies when requested and there is enough work.
fn (TypeChecker) check_semantics_reachable #
fn (mut tc TypeChecker) check_semantics_reachable(selected map[string]bool)
check_semantics_reachable validates only selected function declarations and bodies, plus top-level statements in the selected input. It is intended for source shapes that have already proven they cannot declare any other items.
fn (TypeChecker) check_semantics_selected #
fn (mut tc TypeChecker) check_semantics_selected(selected map[string]bool)
check_semantics_selected validates declarations and only the named function bodies. It is used by the function-level incremental compiler after it has proven that every top-level declaration is unchanged.
fn (TypeChecker) clear_c_type_cache #
fn (tc &TypeChecker) clear_c_type_cache()
clear_c_type_cache invalidates C spellings after monomorphization changes concrete type identities and adds materialized generic types.
fn (TypeChecker) clear_field_lookup_cache #
fn (tc &TypeChecker) clear_field_lookup_cache()
fn (TypeChecker) clear_interface_impl_cache #
fn (tc &TypeChecker) clear_interface_impl_cache()
clear_interface_impl_cache invalidates memoized implementer lists after a type-table change.
fn (TypeChecker) clear_resolved_fn_value #
fn (mut tc TypeChecker) clear_resolved_fn_value(id flat.NodeId)
clear_resolved_fn_value removes stale function-value metadata after a later transform proves that an identifier refers to a value declaration.
fn (TypeChecker) collect #
fn (mut tc TypeChecker) collect(a &flat.FlatAst)
fn (TypeChecker) concrete_method_signature_key #
fn (tc &TypeChecker) concrete_method_signature_key(concrete_name string, method string) ?string
fn (TypeChecker) const_int_value #
fn (tc &TypeChecker) const_int_value(name string, seen []string) ?int
const_int_value supports const int value handling for TypeChecker.
fn (TypeChecker) const_int_value_in_module #
fn (tc &TypeChecker) const_int_value_in_module(name string, module_name string, seen []string) ?int
const_int_value_in_module supports const int value handling for a specific module.
fn (TypeChecker) const_owner_module #
fn (tc &TypeChecker) const_owner_module(name string) string
const_owner_module returns the declaration module for a checker-resolved constant key.
fn (TypeChecker) copy_cloned_resolution #
fn (mut tc TypeChecker) copy_cloned_resolution(src_id flat.NodeId, dst_id flat.NodeId)
copy_cloned_resolution copies checker-owned call/function-value resolution metadata from an original node to a transform-created clone.
fn (TypeChecker) declaration_has_attribute #
fn (tc &TypeChecker) declaration_has_attribute(node_id flat.NodeId, name string) bool
declaration_has_attribute reports whether a declaration has the named attribute.
fn (TypeChecker) diagnose_unused_private_declarations #
fn (mut tc TypeChecker) diagnose_unused_private_declarations(used_fns map[string]bool)
fn (TypeChecker) direct_dependencies #
fn (tc &TypeChecker) direct_dependencies(fn_node_id int) []string
direct_dependencies returns canonical dependency names for compatibility.
fn (TypeChecker) direct_dependency_ids #
fn (tc &TypeChecker) direct_dependency_ids(fn_node_id int) []SymbolId
direct_dependency_ids returns the checker-resolved function dependency identities of a function declaration node. The slice is read-only.
fn (TypeChecker) disable_resolution_type_view_cache #
fn (mut tc TypeChecker) disable_resolution_type_view_cache()
disable_resolution_type_view_cache prevents a scoped cache from escaping the phase that allocated it.
fn (TypeChecker) disarm_body_resolve_memo #
fn (tc &TypeChecker) disarm_body_resolve_memo()
disarm_body_resolve_memo deactivates the per-item resolve memo.
fn (TypeChecker) discard_type_cache_overlay_after_forks #
fn (tc &TypeChecker) discard_type_cache_overlay_after_forks()
discard_type_cache_overlay_after_forks reattaches the frozen cache without publishing memoized entries from parallel work. C generation uses this after its workers join because the driver replaces the cache at the end of the stage, and worker-arena values must not escape into the persistent base.
fn (TypeChecker) enable_scoped_parallel_workers #
fn (mut tc TypeChecker) enable_scoped_parallel_workers()
enable_scoped_parallel_workers uses disposable prealloc arenas for parallel checker helpers. Ownership checking keeps its existing long-lived workers.
fn (TypeChecker) ensure_private_transform_signatures #
fn (mut tc TypeChecker) ensure_private_transform_signatures()
ensure_private_transform_signatures detaches the signature tables before a transform worker writes them. The worker's private maps are merged while its disposable arena is still alive.
fn (TypeChecker) ensure_private_transform_structs #
fn (mut tc TypeChecker) ensure_private_transform_structs()
ensure_private_transform_structs detaches struct metadata before a transform worker publishes a generated capture context into its private result.
fn (TypeChecker) expr_is_method_value #
fn (tc &TypeChecker) expr_is_method_value(id flat.NodeId) bool
expr_is_method_value reports whether id is a selector that resolves to a method value — a struct/interface method used as a value (obj.draw), not a field access or a method call. cgen backs such values with per-instance closure contexts.
fn (TypeChecker) expr_type #
fn (tc &TypeChecker) expr_type(id flat.NodeId) ?Type
expr_type returns the resolved type recorded for a node during annotate_types.
fn (TypeChecker) fixed_array_len_value #
fn (tc &TypeChecker) fixed_array_len_value(arr ArrayFixed) ?int
fixed_array_len_value returns the evaluated fixed-array length when it can be resolved.
fn (TypeChecker) fn_body_definitely_returns #
fn (tc &TypeChecker) fn_body_definitely_returns(node flat.Node) bool
fn_body_definitely_returns supports fn body definitely returns handling for TypeChecker.
fn (TypeChecker) fn_param_types_for_name #
fn (tc &TypeChecker) fn_param_types_for_name(name string) []Type
fn_param_types_for_name returns the collected parameter types for a resolved call name.
fn (TypeChecker) fn_signature_type #
fn (tc &TypeChecker) fn_signature_type(name string, typ string) Type
fn_signature_type resolves a raw function signature type in its declaration module.
fn (TypeChecker) fork_for_parallel_codegen #
fn (tc &TypeChecker) fork_for_parallel_codegen() &TypeChecker
fork_for_parallel_codegen returns a complete read-only semantic view with private scope and memoization state for one C-generation worker.
fn (TypeChecker) fork_for_parallel_transform #
fn (tc &TypeChecker) fork_for_parallel_transform(ast &flat.FlatAst) &TypeChecker
fork_for_parallel_transform returns a TypeChecker that shares all of tc's read-only data (semantic maps and node-indexed cache arrays, which the transform pass only reads) but owns a fresh, private type_cache and a private AST view. During transform the only hidden mutation a TypeChecker performs through its & receiver is memoization into type_cache (parse_type / c_type); giving each worker its own cache makes concurrent use race-free without cloning the large semantic maps. ast must be the worker's own (cloned) FlatAst so that any expr_type lookup on a freshly-created node id indexes a valid array.
fn (TypeChecker) free_parallel_transform_caches #
fn (mut tc TypeChecker) free_parallel_transform_caches()
free_parallel_transform_caches releases private memoization maps owned by a forked transform checker and leaves it valid if it is accidentally read again.
fn (TypeChecker) freeze_interface_impl_names #
fn (mut tc TypeChecker) freeze_interface_impl_names()
freeze_interface_impl_names snapshots the interface implementation order used by transform-generated _typ checks before later metadata cleanup can remove unused generic declarations and shift cgen's ids.
fn (TypeChecker) freeze_pre_transform_interface_impl_names #
fn (mut tc TypeChecker) freeze_pre_transform_interface_impl_names()
freeze_pre_transform_interface_impl_names freezes the immutable implementer indexes prepared before transform. Transform does not add declarations; later generic implementers remain discoverable because the matching candidate set is frozen with the indexes.
fn (TypeChecker) freeze_type_cache_for_forks #
fn (tc &TypeChecker) freeze_type_cache_for_forks()
freeze_type_cache_for_forks freezes this checker's warm type cache as the shared read-only base for parallel forks (fork_for_parallel_transform picks it up) and switches the checker itself to a private overlay so its own memoization writes cannot race fork reads. Callable on a shared reference: the transformer holds the checker as &TypeChecker.
fn (TypeChecker) frozen_symbol_name #
fn (tc &TypeChecker) frozen_symbol_name(id SymbolId) string
frozen_symbol_name resolves an id after semantic checking has frozen the compilation's symbol table. Post-check reachability runs concurrently only with read-only transform preparation, so it does not need the interner lock.
fn (TypeChecker) generic_type_name_matches #
fn (tc &TypeChecker) generic_type_name_matches(a string, b string) bool
fn (TypeChecker) has_fn_decl_short_name #
fn (tc &TypeChecker) has_fn_decl_short_name(name string) bool
has_fn_decl_short_name reports whether collection indexed a function declaration with the given unqualified name.
fn (TypeChecker) ierror_impl_names #
fn (tc &TypeChecker) ierror_impl_names() []string
ierror_impl_names returns the concrete struct names that can be boxed as IError.
fn (TypeChecker) index_operator_call_info #
fn (tc &TypeChecker) index_operator_call_info(base_type Type, op string) ?CallInfo
fn (TypeChecker) index_overload_call_info #
fn (tc &TypeChecker) index_overload_call_info(typ Type, setter bool) ?CallInfo
fn (TypeChecker) inherit_ownership_codegen_metadata_from #
fn (mut tc TypeChecker) inherit_ownership_codegen_metadata_from(_ &TypeChecker)
fn (TypeChecker) interface_abstract_method_names #
fn (tc &TypeChecker) interface_abstract_method_names(iface_name string) []string
interface_abstract_method_names returns the methods an implementer must provide: the interface's own declared (abstract) methods plus those of any embedded interfaces. Default methods defined directly on the interface are excluded.
fn (TypeChecker) interface_accepts_implicit_str #
fn (tc &TypeChecker) interface_accepts_implicit_str(iface_name string) bool
fn (TypeChecker) interface_concrete_method_keys #
fn (tc &TypeChecker) interface_concrete_method_keys() []string
interface_concrete_method_keys returns generated interface dispatch methods and concrete method declarations that can be called by those dispatch functions.
fn (TypeChecker) interface_field_list #
fn (tc &TypeChecker) interface_field_list(iface_name string) []StructField
interface_field_list supports interface field list handling for TypeChecker.
fn (TypeChecker) interface_impl_names #
fn (tc &TypeChecker) interface_impl_names(iface_name string) []string
interface_impl_names returns the concrete type names (structs and type aliases) that implement iface_name. Once a snapshot is frozen, its names stay first so transform-emitted interface IDs are preserved; later implementers are appended in deterministic discovery order.
fn (TypeChecker) interface_impl_set_signature #
fn (tc &TypeChecker) interface_impl_set_signature() string
interface_impl_set_signature returns the complete deterministic interface implementer set that controls collision-resolved dispatch IDs for the current program.
fn (TypeChecker) interface_implements_interface #
fn (tc &TypeChecker) interface_implements_interface(actual_name string, expected_name string) bool
interface_implements_interface supports interface implements interface handling for TypeChecker.
fn (TypeChecker) interface_metadata_name #
fn (tc &TypeChecker) interface_metadata_name(name string) string
fn (TypeChecker) interface_method_signature_key #
fn (tc &TypeChecker) interface_method_signature_key(iface_name string, method string) ?string
fn (TypeChecker) interface_type_ids #
fn (tc &TypeChecker) interface_type_ids(iface_name string) map[string]int
interface_type_ids returns the _typ dispatch IDs for an interface, preserving any snapshot IDs emitted before late generic implementers were discovered.
fn (TypeChecker) invalidate_checked_expr_type #
fn (tc &TypeChecker) invalidate_checked_expr_type(idx int)
cached_expr_type supports cached expr type handling for TypeChecker. invalidate_checked_expr_type drops the cached checked type for one node the transformer rewrote in place, so a trust_checked_expr_types resolve cannot return the pre-rewrite type (see resolve_type). Rewrites target ids inside the writer's own disjoint region, so the shared dense flag array sees no concurrent writes to the same slot.
fn (TypeChecker) invalidate_direct_parent_index #
fn (mut tc TypeChecker) invalidate_direct_parent_index()
invalidate_direct_parent_index makes generated-node lookups validate parent metadata.
fn (TypeChecker) invalidate_short_type_name_index #
fn (tc &TypeChecker) invalidate_short_type_name_index()
invalidate_short_type_name_index drops memoized type-name-derived indexes; callers that add or remove entries in the type-name maps after the checker ran (the monomorphizer specializing generic structs/sum types) must invalidate them.
fn (TypeChecker) is_locally_declared_bare_type #
fn (tc &TypeChecker) is_locally_declared_bare_type(name string) bool
is_locally_declared_bare_type reports whether the bare name is a type declared in the current program (main module), which is bare-keyed in the type tables. Such a name denotes that local type, not an unqualified spelling of some other module's type.
fn (TypeChecker) is_veb_context_type #
fn (tc &TypeChecker) is_veb_context_type(typ Type) bool
is_veb_context_type reports whether typ is veb.Context or embeds it.
fn (TypeChecker) iterator_for_in_elem_type #
fn (tc &TypeChecker) iterator_for_in_elem_type(typ Type) ?Type
fn (TypeChecker) iterator_for_in_next_call_info #
fn (tc &TypeChecker) iterator_for_in_next_call_info(typ Type) ?CallInfo
fn (TypeChecker) iterator_for_in_next_call_info_text #
fn (tc &TypeChecker) iterator_for_in_next_call_info_text(type_text string) ?CallInfo
iterator_for_in_next_call_info_text returns the specialized next call metadata for an iterator type.
fn (TypeChecker) materialize_sparse_transform_node_caches #
fn (mut tc TypeChecker) materialize_sparse_transform_node_caches(n int, capacity int)
materialize_sparse_transform_node_caches compacts transform-created semantic entries into dense node-indexed arrays and reserves their expected final capacity before monomorphization appends more nodes.
fn (TypeChecker) multi_expr_tail_types_for_transform #
fn (tc &TypeChecker) multi_expr_tail_types_for_transform(expr_id flat.NodeId, count int) ?[]Type
multi_expr_tail_types_for_transform returns promoted multi-expression tail types for transform lowering without duplicating checker compatibility rules.
fn (TypeChecker) named_type_compatible_with_ierror #
fn (tc &TypeChecker) named_type_compatible_with_ierror(concrete_name string) bool
fn (TypeChecker) named_type_implements_interface #
fn (tc &TypeChecker) named_type_implements_interface(concrete_name string, iface_name string) bool
named_type_implements_interface supports helper handling in types.
fn (TypeChecker) named_type_implements_marker #
fn (tc &TypeChecker) named_type_implements_marker(concrete_name string, target string) bool
fn (TypeChecker) ownership_assignment_reinitializes_moved_value #
fn (tc &TypeChecker) ownership_assignment_reinitializes_moved_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_default_clone_missing_method #
fn (tc &TypeChecker) ownership_default_clone_missing_method(_ Type) ?string
fn (TypeChecker) ownership_drop_entries_at_fn_exit #
fn (tc &TypeChecker) ownership_drop_entries_at_fn_exit(_ string) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_loop_control #
fn (tc &TypeChecker) ownership_drop_entries_at_loop_control(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_loop_iteration #
fn (tc &TypeChecker) ownership_drop_entries_at_loop_iteration(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_propagation #
fn (tc &TypeChecker) ownership_drop_entries_at_propagation(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_return #
fn (tc &TypeChecker) ownership_drop_entries_at_return(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_return_node #
fn (tc &TypeChecker) ownership_drop_entries_at_return_node(_ string, _ flat.NodeId) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_entries_at_scope_exit #
fn (tc &TypeChecker) ownership_drop_entries_at_scope_exit(_ string, _ int) []OwnershipDropEntry
fn (TypeChecker) ownership_drop_type_names #
fn (tc &TypeChecker) ownership_drop_type_names() []string
fn (TypeChecker) ownership_drop_value_type_names #
fn (tc &TypeChecker) ownership_drop_value_type_names() []string
fn (TypeChecker) ownership_expr_creates_owned_value #
fn (tc &TypeChecker) ownership_expr_creates_owned_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_expr_moves_storage #
fn (tc &TypeChecker) ownership_expr_moves_storage(_ flat.NodeId, _ flat.NodeId) bool
fn (TypeChecker) ownership_fn_value_returns_owned #
fn (tc &TypeChecker) ownership_fn_value_returns_owned(_ flat.NodeId, _ string, _ string) bool
fn (TypeChecker) ownership_guard_read_moves_value #
fn (tc &TypeChecker) ownership_guard_read_moves_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_index_read_moves_value #
fn (tc &TypeChecker) ownership_index_read_moves_value(_ flat.NodeId) bool
fn (TypeChecker) ownership_time_spent_us #
fn (tc &TypeChecker) ownership_time_spent_us() i64
ownership_time_spent_us reports the accumulated ownership-analysis time for the dedicated benchmark stage. Compiled-out ownership (no -d ownership) cannot spend time, so this returns 0 by construction in plain builds.
fn (TypeChecker) ownership_type_has_clone_method #
fn (tc &TypeChecker) ownership_type_has_clone_method(typ Type) bool
ownership_type_has_clone_method reports whether typ declares a handwritten clone method. It is kept in the always-built checker surface because ownership transform support is compiled into the V executable even when the executable itself is built without ownership.
fn (TypeChecker) ownership_type_requires_destruction #
fn (tc &TypeChecker) ownership_type_requires_destruction(_ Type) bool
fn (TypeChecker) ownership_type_requires_drop #
fn (tc &TypeChecker) ownership_type_requires_drop(_ Type) bool
fn (TypeChecker) parse_canonical_type #
fn (tc &TypeChecker) parse_canonical_type(typ string) Type
parse_canonical_type parses compiler-produced type text while preserving an exact known qualified symbol before consulting the current file's import aliases. Source text must continue to use parse_type, where aliases take precedence; this entry point is for semantic names carried between phases.
fn (TypeChecker) parse_resolution_type #
fn (tc &TypeChecker) parse_resolution_type(typ string) Type
parse_resolution_type parses type text that can mix declaration-local names with concrete generic arguments from another module.
fn (TypeChecker) parse_type #
fn (tc &TypeChecker) parse_type(typ string) Type
fn (TypeChecker) parse_type_ref #
fn (tc &TypeChecker) parse_type_ref(typ string, text_id u16) Type
parse_type_ref resolves a node annotation through its exact canonical text identity. Context remains part of the key because an unqualified spelling can denote different types in different files/modules.
fn (TypeChecker) pop_scope #
fn (mut tc TypeChecker) pop_scope()
pop_scope updates pop scope state for TypeChecker.
fn (TypeChecker) pre_transform_interface_impl_names #
fn (tc &TypeChecker) pre_transform_interface_impl_names(iface_name string) ?[]string
pre_transform_interface_impl_names returns the immutable implementer snapshot prepared after semantic checking and before generic monomorphization.
fn (TypeChecker) precompute_source_error_embed_index #
fn (tc &TypeChecker) precompute_source_error_embed_index()
precompute_source_error_embed_index builds the immutable source-error embedding index once before parallel consumers fork their private memoization overlays.
fn (TypeChecker) prepare_interface_query_indexes #
fn (mut tc TypeChecker) prepare_interface_query_indexes()
prepare_interface_query_indexes publishes immutable interface requirements and implementer lists for transform workers.
fn (TypeChecker) prepare_interface_requirement_indexes #
fn (mut tc TypeChecker) prepare_interface_requirement_indexes()
prepare_interface_query_indexes publishes immutable interface requirements for transform workers. Interface declarations no longer change after semantic checking, so compatibility scans can reuse these lists safely across threads.
fn (TypeChecker) prepare_threads_condition #
fn (mut tc TypeChecker) prepare_threads_condition()
prepare_threads_condition caches whether selected inputs or their reachable imports use spawn.
fn (TypeChecker) promote_scoped_transform_interners #
fn (mut tc TypeChecker) promote_scoped_transform_interners(type_start int, symbol_start int, scope voidptr)
promote_scoped_transform_interners moves additions made by a scoped transform into the current compilation arena before that scope is freed.
fn (TypeChecker) prune_inactive_top_level_comptime #
fn (tc &TypeChecker) prune_inactive_top_level_comptime(mut a flat.FlatAst)
prune_inactive_top_level_comptime removes declarations and expressions from inactive top-level compile-time branches after semantic checking and before later compiler stages.
fn (TypeChecker) push_scope #
fn (mut tc TypeChecker) push_scope()
push_scope updates push scope state for TypeChecker.
fn (TypeChecker) qualify_fn_name #
fn (tc &TypeChecker) qualify_fn_name(name string) string
qualify_fn_name supports qualify fn name handling for TypeChecker.
fn (TypeChecker) qualify_name #
fn (tc &TypeChecker) qualify_name(name string) string
fn (TypeChecker) rebind_ast #
fn (mut tc TypeChecker) rebind_ast(a &flat.FlatAst)
rebind_ast updates the AST view after the driver clones transformed storage. All collected declaration/type metadata remains valid because cloning preserves node ids.
fn (TypeChecker) rebuild_fn_param_suffix_index #
fn (mut tc TypeChecker) rebuild_fn_param_suffix_index()
rebuild_fn_param_suffix_index refreshes the suffix index after a batch replaces or removes synthesized signatures.
fn (TypeChecker) rebuild_scoped_transform_signature_maps #
fn (mut tc TypeChecker) rebuild_scoped_transform_signature_maps()
rebuild_scoped_transform_signature_maps moves signature maps, keys, and nested type metadata into the current arena after a disposable transform scope has been left.
fn (TypeChecker) record_cgen_error_at #
fn (mut tc TypeChecker) record_cgen_error_at(msg string, node flat.NodeId, source_id flat.NodeId, marker string)
record_cgen_error_at records a post-transform validation error with cgen severity.
fn (TypeChecker) refresh_direct_parent_index #
fn (mut tc TypeChecker) refresh_direct_parent_index(a &flat.FlatAst)
refresh_direct_parent_index rebuilds parent metadata after source-tree pruning.
fn (TypeChecker) refresh_rewritten_parent_index #
fn (mut tc TypeChecker) refresh_rewritten_parent_index(a &flat.FlatAst)
refresh_rewritten_parent_index rebuilds the node-parent edges after transform without resetting declaration metadata collected during semantic checking. Rewritten trees can contain hundreds of thousands of new nodes; leaving those nodes outside direct_parent_ids makes every parent query scan the whole AST.
fn (TypeChecker) register_generated_fn_param_types #
fn (mut tc TypeChecker) register_generated_fn_param_types(name string, params []Type)
register_generated_fn_param_types records a synthesized function signature and keeps the receiver/method suffix index complete for post-check phases.
fn (TypeChecker) register_short_type_name #
fn (tc &TypeChecker) register_short_type_name(name string)
register_short_type_name extends an already-built short-name index after monomorphization adds a concrete type. A scoped transform must not rebuild the entire index from maps whose strings may belong to the checked arena.
fn (TypeChecker) register_synth_type #
fn (mut tc TypeChecker) register_synth_type(id flat.NodeId, typ Type)
register_synth_type records the type of a generated or transformed node.
fn (TypeChecker) reserve_scoped_transform_metadata #
fn (mut tc TypeChecker) reserve_scoped_transform_metadata(signature_headroom int)
reserve_scoped_transform_metadata keeps tables that receive escaping transform additions in the compilation arena in the common case while scratch allocations use a disposable arena. The signature maps are rebuilt after promotion, so this headroom is an optimization rather than an ownership requirement.
fn (TypeChecker) reserve_transform_node_caches #
fn (mut tc TypeChecker) reserve_transform_node_caches(n int)
reserve_transform_node_caches reserves node-indexed semantic storage before a scoped transform starts, keeping the escaping slabs in the compilation arena.
fn (TypeChecker) reset_body_resolve_memo #
fn (tc &TypeChecker) reset_body_resolve_memo()
reset_body_resolve_memo detaches the memo entirely. The transformer arms it inside a disposable stage arena, so the master checker must drop the pointer before that arena is released — later phases would otherwise dereference a freed allocation just to see that the memo is inactive.
fn (TypeChecker) reset_resolution_type_view_cache #
fn (mut tc TypeChecker) reset_resolution_type_view_cache()
reset_resolution_type_view_cache discards lookup views that may have been created inside a completed scoped parallel phase.
fn (TypeChecker) reset_resolved_calls_for_reannotation #
fn (mut tc TypeChecker) reset_resolved_calls_for_reannotation()
reset_resolved_calls_for_reannotation discards pre-transform call-name bindings before the transformed AST is annotated again. The annotation walk resolves and records every reachable call against the final AST/signatures.
fn (TypeChecker) reset_type_interners #
fn (mut tc TypeChecker) reset_type_interners()
reset_type_interners replaces semantic interners whose backing storage may have grown inside a disposable compiler-stage arena.
fn (TypeChecker) resolve_any_selective_import_fn #
fn (tc &TypeChecker) resolve_any_selective_import_fn(name string) ?string
resolve_any_selective_import_fn resolves an unqualified selected function when every source file that selects the name agrees on the same declaration.
fn (TypeChecker) resolve_generic_struct_method #
fn (tc &TypeChecker) resolve_generic_struct_method(type_name string, method string) ?CallInfo
resolve_type_name_for_method resolves resolve type name for method information for types. resolve_generic_struct_method resolves a method call on a generic-struct instance (e.g. Vec4[f32].r_sqrt). The method is registered against the generic form (Vec4[T].r_sqrt); this maps the instance's concrete type arguments onto the generic parameters and substitutes them into the method's signature, so the pre-transform checker accepts the call. The transformer's monomorphize pass later materialises the concrete method body.
fn (TypeChecker) resolve_generic_sum_method #
fn (tc &TypeChecker) resolve_generic_sum_method(type_name string, method string) ?CallInfo
fn (TypeChecker) resolve_ierror_payload_name #
fn (tc &TypeChecker) resolve_ierror_payload_name(name string) string
resolve_ierror_payload_name resolves scoped Error/MessageError names before falling back to the builtin error structs.
fn (TypeChecker) resolve_imported_type_text_in_file #
fn (tc &TypeChecker) resolve_imported_type_text_in_file(typ string, file string) string
fn (TypeChecker) resolve_type #
fn (tc &TypeChecker) resolve_type(id flat.NodeId) Type
fn (TypeChecker) resolved_call_is_builtin #
fn (tc &TypeChecker) resolved_call_is_builtin(id flat.NodeId, name string) bool
resolved_call_is_builtin reports whether id resolved to the named builtin function.
fn (TypeChecker) resolved_call_name #
fn (tc &TypeChecker) resolved_call_name(id flat.NodeId) ?string
resolved_call_name returns the checker-resolved function name for a call node.
fn (TypeChecker) resolved_call_never_returns #
fn (tc &TypeChecker) resolved_call_never_returns(id flat.NodeId) bool
resolved_call_never_returns reports whether a call node resolved to a known no-return function.
fn (TypeChecker) resolved_fn_value_name #
fn (tc &TypeChecker) resolved_fn_value_name(id flat.NodeId) ?string
resolved_fn_value_name returns the checker-resolved function name for a function value node.
fn (TypeChecker) reuse_direct_parent_index_for_unchanged_ast #
fn (mut tc TypeChecker) reuse_direct_parent_index_for_unchanged_ast(a &flat.FlatAst) bool
reuse_direct_parent_index_for_unchanged_ast restores the parsed-tree index's trusted status when an internal valid-build path has not structurally rewritten the AST.
fn (TypeChecker) runtime_type_index_names #
fn (tc &TypeChecker) runtime_type_index_names() []string
runtime_type_index_names returns the canonical program type names that can participate in runtime interface/sum type_idx() lowering.
fn (TypeChecker) scoped_parallel_workers_enabled #
fn (tc &TypeChecker) scoped_parallel_workers_enabled() bool
scoped_parallel_workers_enabled reports whether compiler stages should use short-lived worker arenas with this checker.
fn (TypeChecker) selector_const_type #
fn (tc &TypeChecker) selector_const_type(node flat.Node) ?Type
selector_const_type returns the declared type for a selector const expression.
fn (TypeChecker) set_fresh_type_cache #
fn (mut tc TypeChecker) set_fresh_type_cache(parse_enabled bool)
set_fresh_type_cache attaches a new empty TypeCache. Parallel-cgen worker checkers use this so the lazily-built lookup indexes and memoizations work per worker instead of falling back to their uncached full scans.
fn (TypeChecker) set_fresh_type_cache_based_on #
fn (mut tc TypeChecker) set_fresh_type_cache_based_on(src &TypeChecker, parse_enabled bool)
set_fresh_type_cache_based_on attaches a new empty TypeCache that falls back read-only to src's frozen base cache (see freeze_type_cache_for_forks), so parallel-cgen workers start with every type memoized by the check/transform phases instead of re-deriving them from a cold cache.
fn (TypeChecker) struct_field_c_abi_fn_ptr_type #
fn (tc &TypeChecker) struct_field_c_abi_fn_ptr_type(struct_name string, field_name string) ?string
struct_field_c_abi_fn_ptr_type returns the C ABI function-pointer type for a struct field.
fn (TypeChecker) struct_field_type_name #
fn (tc &TypeChecker) struct_field_type_name(struct_name string, field_name string) ?string
struct_field_type_name returns the canonical type name for a struct field.
fn (TypeChecker) struct_fields_for_type #
fn (tc &TypeChecker) struct_fields_for_type(struct_name string) []StructField
struct_fields_for_type returns the fields of struct_name, with generic parameters substituted when struct_name is a concrete generic instance.
fn (TypeChecker) struct_module_for_type #
fn (tc &TypeChecker) struct_module_for_type(name string) string
struct_module_for_type returns the module that declared the named struct.
fn (TypeChecker) sum_variant_type_for_pattern #
fn (tc &TypeChecker) sum_variant_type_for_pattern(sum_name string, variant_name string) ?string
fn (TypeChecker) symbol_count #
fn (tc &TypeChecker) symbol_count() int
symbol_count returns the number of resolved names interned by the checker.
fn (TypeChecker) symbol_name #
fn (tc &TypeChecker) symbol_name(id SymbolId) string
symbol_name resolves a checker symbol identity to its canonical name.
fn (TypeChecker) threads_condition_value #
fn (tc &TypeChecker) threads_condition_value() bool
threads_condition_value reports the cached $if threads condition, scanning lazily for direct TypeChecker users that do not run the regular compiler setup.
fn (TypeChecker) transform_signatures_changed #
fn (tc &TypeChecker) transform_signatures_changed() bool
transform_signatures_changed reports whether a transform fork detached and added signature state that its parent must merge.
fn (TypeChecker) type_cache_parse_enabled #
fn (tc &TypeChecker) type_cache_parse_enabled() bool
type_cache_parse_enabled reports whether parse_type memoization is enabled on this checker's type cache.
fn (TypeChecker) type_cache_stats #
fn (tc &TypeChecker) type_cache_stats() TypeCacheStats
type_cache_stats returns cache counters accumulated by this checker.
fn (TypeChecker) type_count #
fn (tc &TypeChecker) type_count() int
type_count reports the number of unique canonical semantic types observed by this compilation.
fn (TypeChecker) type_has_implicit_str_method #
fn (tc &TypeChecker) type_has_implicit_str_method(name string) bool
fn (TypeChecker) type_name #
fn (tc &TypeChecker) type_name(t Type) string
type_name lazily formats and memoizes the canonical spelling of a semantic type. Hot compiler paths should prefer this to repeated recursive Type.name construction.
fn (TypeChecker) type_text_implements_interface #
fn (mut tc TypeChecker) type_text_implements_interface(actual_text string, iface_text string) bool
type_text_implements_interface reports whether a concrete type expression satisfies an interface type expression in the current checker module context.
fn (TypeChecker) unfreeze_type_cache_after_forks #
fn (tc &TypeChecker) unfreeze_type_cache_after_forks()
unfreeze_type_cache_after_forks folds the private overlay back into the frozen base once every fork has been joined, and reattaches the base as the live cache.
fn (TypeChecker) unregister_short_type_name #
fn (tc &TypeChecker) unregister_short_type_name(name string)
unregister_short_type_name removes an exact cached entry when a generic template is erased. Ambiguous entries stay conservative until the next compilation-wide index build.
struct TypeError #
struct TypeError {
pub:
msg string
kind TypeErrorKind
node flat.NodeId
file string
node_kind string
node_value string
node_pos string
pos token.Pos
details []string
severity string
}
TypeError represents type error data used by types.
struct USize #
struct USize {
dummy_ u8
}
USize represents usize data used by types.
struct Unknown #
struct Unknown {
pub:
reason string
}
Unknown represents unknown data used by types.
struct Void #
struct Void {
dummy_ u8
}
Void represents void data used by types.
- README
- Constants
- fn builtin_type
- fn builtin_type_value
- fn clone_owned_type
- fn clone_owned_types
- fn defer_result_index
- fn extend_stable_type_indexes
- fn extend_stable_type_indexes_ref
- fn generic_base_name
- fn is_builtin_type_name
- fn new_scope
- fn stable_interface_type_ids
- fn stable_interface_type_ids_preserving_prefix
- fn stable_type_index
- fn stable_type_indexes
- fn type_text_contains_typeof
- fn unalias_type
- fn unsigned_shift_result_type
- fn unwrap_all_pointers
- fn unwrap_pointer
- fn Properties.from
- fn Properties.zero
- fn ReceiverMutationVisibility.from
- fn RecursiveStrAggregateSlotKind.from
- fn RecursiveStrMutationEffect.from
- fn TypeChecker.new
- fn TypeErrorKind.from
- type SymbolId
- type Type
- type TypeId
- enum Properties
- enum TypeErrorKind
- struct Alias
- struct Array
- struct ArrayFixed
- struct CallInfo
- struct Channel
- struct Char
- struct Enum
- struct FnType
- struct ISize
- struct Interface
- struct InterfaceImplIndex
- struct Map
- struct MultiReturn
- struct Nil
- struct None
- struct OptionType
- struct OwnershipDropEntry
- struct Pointer
- struct Primitive
- struct QualifyNameCache
- struct ResultType
- struct Rune
- struct Scope
- struct ScopeBindingOwner
- struct String
- struct Struct
- struct StructField
- struct SumType
- struct TransformForkOverlay
- struct TypeCacheStats
- struct TypeChecker
- fn annotate_types
- fn annotate_types_with_used
- fn annotate_types_with_used_missing_calls
- fn arm_body_resolve_memo
- fn autofree_enabled
- fn begin_sparse_transform_node_caches
- fn c_type
- fn cached_c_name
- fn canonical_qualified_type_name
- fn canonical_symbol
- fn check_concrete_fn_semantics
- fn check_interface_embedding_limits
- fn check_main_module_requirement
- fn check_semantics
- fn check_semantics_opt
- fn check_semantics_reachable
- fn check_semantics_selected
- fn clear_c_type_cache
- fn clear_field_lookup_cache
- fn clear_interface_impl_cache
- fn clear_resolved_fn_value
- fn collect
- fn concrete_method_signature_key
- fn const_int_value
- fn const_int_value_in_module
- fn const_owner_module
- fn copy_cloned_resolution
- fn declaration_has_attribute
- fn diagnose_unused_private_declarations
- fn direct_dependencies
- fn direct_dependency_ids
- fn disable_resolution_type_view_cache
- fn disarm_body_resolve_memo
- fn discard_type_cache_overlay_after_forks
- fn enable_scoped_parallel_workers
- fn ensure_private_transform_signatures
- fn ensure_private_transform_structs
- fn expr_is_method_value
- fn expr_type
- fn fixed_array_len_value
- fn fn_body_definitely_returns
- fn fn_param_types_for_name
- fn fn_signature_type
- fn fork_for_parallel_codegen
- fn fork_for_parallel_transform
- fn free_parallel_transform_caches
- fn freeze_interface_impl_names
- fn freeze_pre_transform_interface_impl_names
- fn freeze_type_cache_for_forks
- fn frozen_symbol_name
- fn generic_type_name_matches
- fn has_fn_decl_short_name
- fn ierror_impl_names
- fn index_operator_call_info
- fn index_overload_call_info
- fn inherit_ownership_codegen_metadata_from
- fn interface_abstract_method_names
- fn interface_accepts_implicit_str
- fn interface_concrete_method_keys
- fn interface_field_list
- fn interface_impl_names
- fn interface_impl_set_signature
- fn interface_implements_interface
- fn interface_metadata_name
- fn interface_method_signature_key
- fn interface_type_ids
- fn invalidate_checked_expr_type
- fn invalidate_direct_parent_index
- fn invalidate_short_type_name_index
- fn is_locally_declared_bare_type
- fn is_veb_context_type
- fn iterator_for_in_elem_type
- fn iterator_for_in_next_call_info
- fn iterator_for_in_next_call_info_text
- fn materialize_sparse_transform_node_caches
- fn multi_expr_tail_types_for_transform
- fn named_type_compatible_with_ierror
- fn named_type_implements_interface
- fn named_type_implements_marker
- fn ownership_assignment_reinitializes_moved_value
- fn ownership_default_clone_missing_method
- fn ownership_drop_entries_at_fn_exit
- fn ownership_drop_entries_at_loop_control
- fn ownership_drop_entries_at_loop_iteration
- fn ownership_drop_entries_at_propagation
- fn ownership_drop_entries_at_return
- fn ownership_drop_entries_at_return_node
- fn ownership_drop_entries_at_scope_exit
- fn ownership_drop_type_names
- fn ownership_drop_value_type_names
- fn ownership_expr_creates_owned_value
- fn ownership_expr_moves_storage
- fn ownership_fn_value_returns_owned
- fn ownership_guard_read_moves_value
- fn ownership_index_read_moves_value
- fn ownership_time_spent_us
- fn ownership_type_has_clone_method
- fn ownership_type_requires_destruction
- fn ownership_type_requires_drop
- fn parse_canonical_type
- fn parse_resolution_type
- fn parse_type
- fn parse_type_ref
- fn pop_scope
- fn pre_transform_interface_impl_names
- fn precompute_source_error_embed_index
- fn prepare_interface_query_indexes
- fn prepare_interface_requirement_indexes
- fn prepare_threads_condition
- fn promote_scoped_transform_interners
- fn prune_inactive_top_level_comptime
- fn push_scope
- fn qualify_fn_name
- fn qualify_name
- fn rebind_ast
- fn rebuild_fn_param_suffix_index
- fn rebuild_scoped_transform_signature_maps
- fn record_cgen_error_at
- fn refresh_direct_parent_index
- fn refresh_rewritten_parent_index
- fn register_generated_fn_param_types
- fn register_short_type_name
- fn register_synth_type
- fn reserve_scoped_transform_metadata
- fn reserve_transform_node_caches
- fn reset_body_resolve_memo
- fn reset_resolution_type_view_cache
- fn reset_resolved_calls_for_reannotation
- fn reset_type_interners
- fn resolve_any_selective_import_fn
- fn resolve_generic_struct_method
- fn resolve_generic_sum_method
- fn resolve_ierror_payload_name
- fn resolve_imported_type_text_in_file
- fn resolve_type
- fn resolved_call_is_builtin
- fn resolved_call_name
- fn resolved_call_never_returns
- fn resolved_fn_value_name
- fn reuse_direct_parent_index_for_unchanged_ast
- fn runtime_type_index_names
- fn scoped_parallel_workers_enabled
- fn selector_const_type
- fn set_fresh_type_cache
- fn set_fresh_type_cache_based_on
- fn share_direct_dependencies_from
- fn struct_field_c_abi_fn_ptr_type
- fn struct_field_is_shared
- fn struct_field_type_name
- fn struct_fields_for_type
- fn struct_module_for_type
- fn sum_variant_type_for_pattern
- fn symbol_count
- fn symbol_name
- fn threads_condition_value
- fn transform_signatures_changed
- fn type_cache_parse_enabled
- fn type_cache_stats
- fn type_count
- fn type_has_implicit_str_method
- fn type_name
- fn type_text_implements_interface
- fn unfreeze_type_cache_after_forks
- fn unregister_short_type_name
- struct TypeError
- struct USize
- struct Unknown
- struct Void