Add tuple type recomputation after inlining
Introduce helper functions to recompute the `StaticType` of a tuple node based on its children's types. This ensures that after inlining, tuples within the AST have concrete types, rather than unresolved type variables, even when derived from polymorphic functions. Also adds tests to verify this behavior for both homogeneous and heterogeneous tuples.
This commit is contained in:
@@ -216,3 +216,36 @@ fn test_slot_reuse_non_overlapping_scopes() {
|
||||
dump
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tuple type recomputation after inlining ─────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn test_inlined_tuple_has_concrete_type_homogeneous() {
|
||||
// A polymorphic function returning a tuple, called with all-Int args.
|
||||
// After inlining, the tuple type must be concrete (no unresolved TypeVars).
|
||||
let env = Environment::new();
|
||||
let source = r#"(do
|
||||
(def wrap (fn [x y z] [x y z]))
|
||||
(wrap 1 2 3)
|
||||
)"#;
|
||||
let dump = env.dump_ast_compact(source).unwrap();
|
||||
assert!(
|
||||
!dump.contains('?'),
|
||||
"Inlined tuple must not contain unresolved TypeVars. Dump:\n{dump}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inlined_tuple_has_concrete_type_heterogeneous() {
|
||||
// Heterogeneous case: Int + String should produce Tuple([int, str]), not ?0/?1.
|
||||
let env = Environment::new();
|
||||
let source = r#"(do
|
||||
(def wrap (fn [x y] [x y]))
|
||||
(wrap 1 "hello")
|
||||
)"#;
|
||||
let dump = env.dump_ast_compact(source).unwrap();
|
||||
assert!(
|
||||
!dump.contains('?'),
|
||||
"Inlined tuple must not contain unresolved TypeVars. Dump:\n{dump}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user