Generic calls use ordinary syntax. Immediate evidence selects generic types. An existing numeric origin can also stay linked through a generic signature until an exact receiving use resolves it within the same body.
Inference from an argument
identity type A |value A| -> A:
return value
;
value = identity(42)
With no other exact numeric constraint in the body, the whole-number origin defaults to I32, so A resolves to I32.
Inference from the result type
empty type A || -> {A}:
return {}
;
items {I32} = empty()
The immediate receiving type says the result is {I32}, so A becomes I32.
Generic calls use ordinary syntax. Ordinary type parameters come from immediate evidence. A bounded numeric-origin exception lets an existing numeric unknown pass through a generic signature's parameter and result before the caller body defaults it.
Inference sources
identity type A |value A| -> A:
return value
;
empty type A || -> {A}:
return {}
;
accept_u64 |value U64|:
;
value = identity(42)
typed_value I32 = identity(42)
items {I32} = empty()
forwarded = identity(1)
accept_u64(forwarded)
Ordinary generic types come from immediate arguments or an immediate expected result shape. When an argument already contains a numeric origin, a signature such as A -> A may share that origin between parameter and result. Eligible exact receivers can resolve the retained origin through direct uses later in the same function body, including connected copies and writes. In the final call above, the generic signature alone carries the whole-number origin to the U64 parameter receiver. See Numeric literals for the full inference contract.
The compiler does not inspect the callee body or search trait evidence to select a numeric type. Generic declarations, instances and public interfaces contain declared type parameters or completed exact types, never pending numeric identities.
What inference does not use
values = empty()
Outside the bounded numeric-origin relation above, later use does not infer a generic parameter. In particular, inference does not search:
- later mutation or later reads to create an otherwise missing type
- whole-program uses, another function body or HIR
- borrow validation or trait implementations
- distant return uses
- an outer call's parameter context into a nested generic call
- backward from an operation result into already named operands
An existing numeric origin can be shared through a known collection, map, nominal/generic or optional shape while the shape, capacity, key restrictions, constructor identity and nonnumeric types remain fixed. This does not infer anonymous structure or turn an empty container into a numeric origin.
Use an intermediate annotation when a nested generic call has no immediate evidence.
empty type A || -> {A}:
return {}
;
consume |values {I32}|:
;
consume(empty())
items {I32} = empty()
consume(items)
Never generic calls
A generic function declared -> ! has no result shape. Inference uses the immediate arguments only. There is no expected result type to solve a parameter.
abort type A |value A| -> !:
assert(false, "aborted")
;
abort("unreachable")
A Never call remains a standalone statement, so it cannot sit at a typed receiving site that would otherwise supply result evidence.
Optional and fallible generic returns
Generic functions may return optional or fallible values when the concrete envelope is solved by immediate evidence.
wrap_optional type T |value T| -> T?:
return value
;
always_fail type T, E |fallback T, err E| -> T, E!:
return! err
;
maybe_name String? = wrap_optional("Priya")
value = always_fail(7, Error("bad")) catch |err| then 0
A bare none cannot infer an otherwise unknown parameter by itself.
Imported generic functions
Visible imported generic functions use the same local inference rules. There is no explicit call-site type argument syntax.
Cast boundary
A cast target does not constrain the source type. Resolve the generic call's source independently from eligible exact receivers for its retained numeric origin, then apply the ordinary default if none resolves it. The cast classifies the completed source/target pair.
Generic error parameter inference
A concrete callee error type does not specialise an otherwise unsolved generic error parameter merely because it appears inside the generic body. Immediate declaration and call-site evidence must still solve the parameter.
generic_fail type E || -> I32, E!:
return! Error("bad")
;
A generic error parameter must be solved by immediate call-site evidence, like any other generic parameter.
Explicit call-site syntax is rejected
All of these are rejected:
identity of I32(42)
identity<I32>(42)
identity[I32](42)
identity(42 I32)
Concepts related to generic inference