Problem
The StaticType::Tuple variant is structural — it encodes the exact element types and arity (e.g. Tuple(Int, Int, Int)). This means there is no way to express "any tuple" in the type system, which causes two issues:
1. Can't write typed overloads that accept any tuple
When registering overloads for operators like [], we can provide specific signatures for List<Any>, String, Deque<Any>, and Map<Any, Any>, but for tuples we have to fall back to (Any, Any) -> Any because Tuple(vec![]) means "empty tuple" (unit), not "tuple of any shape".
This is visible in Value::matches_param which returns false for all Tuple(_) parameters during dynamic dispatch, since verifying element types would require scanning.
2. Indexing is the only way to extract tuple elements
Currently the only mechanism to get values out of a tuple is the [] index operator with an integer index (e.g. t[0], t[1]). This is clunky and loses all type information — the return type is always Any.
Other languages solve this with destructuring/pattern matching:
Possible directions
- Add a
StaticType::AnyTuple variant (or treat Tuple(vec![]) as a wildcard) so typed overloads can accept tuples
- Add tuple destructuring syntax so elements can be extracted with known types
- Both — destructuring for ergonomics, wildcard tuple type for the internal type system
Problem
The
StaticType::Tuplevariant is structural — it encodes the exact element types and arity (e.g.Tuple(Int, Int, Int)). This means there is no way to express "any tuple" in the type system, which causes two issues:1. Can't write typed overloads that accept any tuple
When registering overloads for operators like
[], we can provide specific signatures forList<Any>,String,Deque<Any>, andMap<Any, Any>, but for tuples we have to fall back to(Any, Any) -> AnybecauseTuple(vec![])means "empty tuple" (unit), not "tuple of any shape".This is visible in
Value::matches_paramwhich returnsfalsefor allTuple(_)parameters during dynamic dispatch, since verifying element types would require scanning.2. Indexing is the only way to extract tuple elements
Currently the only mechanism to get values out of a tuple is the
[]index operator with an integer index (e.g.t[0],t[1]). This is clunky and loses all type information — the return type is alwaysAny.Other languages solve this with destructuring/pattern matching:
Possible directions
StaticType::AnyTuplevariant (or treatTuple(vec![])as a wildcard) so typed overloads can accept tuples