Refactor type checker for series and overloads
Introduce `unify_matched_overload` to handle type variable propagation for overloaded functions. This ensures that when an overload is chosen, its concrete parameter types are unified with the actual argument types. This is crucial for resolving type variables nested within closures called through overloaded functions. Additionally, this commit: - Allows `series` to infer schema type from `push` calls, simplifying its signature. - Adds a fallback to `ValueSeries` in `rtl::series` if schema injection fails. - Updates `StaticType::TypeVar` to return `Any` when accessed, simplifying field access logic. - Adjusts tests to reflect the simplified `series` signature.
This commit is contained in:
@@ -24,6 +24,14 @@ pub fn register(env: &Environment) {
|
||||
Purity::Impure,
|
||||
|args: &[Value]| {
|
||||
let lookback_limit = args[0].as_int().unwrap_or(0) as usize;
|
||||
// The type checker injects the schema as a second argument via HM inference.
|
||||
// If schema injection was not possible (e.g. the first push is inside a nested
|
||||
// closure that the type checker could not reach), fall back to a ValueSeries
|
||||
// that stores unboxed Values. The HM type checker still guarantees type safety
|
||||
// at compile time; this path is only a runtime fallback for storage allocation.
|
||||
if args.len() < 2 {
|
||||
return Value::Series(Rc::new(ValueSeries::new(lookback_limit)));
|
||||
}
|
||||
let arg = &args[1];
|
||||
match arg {
|
||||
Value::Keyword(k) => {
|
||||
|
||||
Reference in New Issue
Block a user