Add IndexElementFn for series type probing
Introduce `IndexElementFn` as a type alias for a function that maps a `StaticType` to an optional `StaticType` representing its element type. This allows the `TypeChecker` to determine the element type of indexable types like `Series` without needing to be aware of their specific implementations. The `series_element_type` function is created and registered with the `TypeChecker` to handle `Series` types. This design centralizes type-specific logic for indexable types, making the `TypeChecker` more generic and extensible for future indexable types such as `Stream`.
This commit is contained in:
@@ -36,6 +36,16 @@ pub trait TypeInferenceAccess {
|
||||
fn try_record_promote(&self, a: &StaticType, b: &StaticType) -> Option<StaticType>;
|
||||
}
|
||||
|
||||
/// Maps a concrete type to its element type for index-constraint propagation.
|
||||
/// Called by `bind_var` when a TypeVar with an index constraint is bound.
|
||||
///
|
||||
/// Returns `Some(elem_ty)` if `ty` supports integer-index access (e.g. `Series`),
|
||||
/// or `None` for all non-indexable types.
|
||||
///
|
||||
/// Register the appropriate implementation via `TypeChecker::new`. Each indexable
|
||||
/// type (Series, and in future Stream) contributes a match arm here.
|
||||
pub type IndexElementFn = fn(&StaticType) -> Option<StaticType>;
|
||||
|
||||
/// Called after the call's return type is resolved.
|
||||
/// May replace the return type and/or perform unification side-effects (e.g. push).
|
||||
pub type PostCallHook = fn(
|
||||
|
||||
Reference in New Issue
Block a user