Remove IndexElementFn and series_element_type

The `IndexElementFn` trait and its associated `series_element_type`
function have been removed. The `TypeChecker` now directly inspects the
`StaticType::Series` variant to extract the element type when
propagating index constraints. This simplifies the type-checking logic
by removing an unnecessary layer of indirection and adhering to the
project rule of keeping the AST simple and pushing complexity into the
system.
This commit is contained in:
2026-03-29 14:00:48 +02:00
parent 0292ead7a5
commit 916460ab03
4 changed files with 12 additions and 44 deletions
-15
View File
@@ -15,21 +15,6 @@ use crate::ast::types::{NativeFunction, NodeIdentity, Purity, Signature, SourceL
// 4. Type-Inference Hooks (registered via RTL bootstrap, no name coupling)
// ============================================================================
/// Index-element hook for the `Series` type.
///
/// Returns the element type of a `Series(inner)`, or `None` for all other types.
/// Registered with `TypeChecker` so that the core type-checker remains agnostic
/// about which concrete types support integer-index access.
///
/// When `Stream` (or future indexable types) is added, extend this function
/// with additional match arms rather than touching the type-checker.
pub(crate) fn series_element_type(ty: &StaticType) -> Option<StaticType> {
match ty {
StaticType::Series(inner) => Some(*inner.clone()),
_ => None,
}
}
/// Post-call hook for `(series n)`.
/// Replaces the `Series(Any)` return type with a fresh TypeVar so that
/// subsequent `push` calls can unify the element type (HM inference).