You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Soundness] call_shape, call_result_tys, ty_of_expr, and multi_value_tys drop return shapes and TypeExprs on function-value calls and container projections, bypassing HYB-E3003 / HYB-E3004 #1042
In compiler/crates/hy-check/src/shape.rs, four shape/type inference helpers (call_shape, call_result_tys, ty_of_expr, and multi_value_tys) silently drop return shapes (TypeShape::Unknown) or source types (None) across indirect function-value calls and container projections:
call_shape's Expr::Ident arm matches &b.ty directly against Some(TypeExpr::Fn { .. }) without calling self.resolve_type_alias(ty) (unlike ty_of_expr and call_result_tys), so calling a local binding ascribed with a function type alias (type getter = fn(x map[string]int) map[string]int) degrades to TypeShape::Unknown.
Neither call_shape nor call_result_tys falls back to self.ty_of_expr(st, callee) -> self.resolve_type_alias(&callee_ty) -> TypeExpr::Fn { results, .. } in the Expr::Field and _ arms (unlike ty_of_expr lines 782-795 and sendability.rs::dir_ty_of_expr lines 3038-3054). Consequently, calling a struct field of function type (h.cb(m) or p.cb(m)), an indexed function table (cbs[0](m)), or a channel-received function value degrades all return shapes to TypeShape::Unknown.
Unlike sendability.rs::dir_ty_of_expr, ty_of_expr has no arms for Expr::Slice (s[:]), Expr::Receive (<-ch), Expr::AddrOf / Expr::Unary { op: UnOp::Addr } (&box), "append" (append(s, f)), or "make" on a type-alias identifier (make(fn_map)), and Expr::Field does not fall back to self.shape_of_expr(st, base) when base is a pointer/struct whose TypeShape is known.
multi_value_tys matches self.ty_of_expr(st, base) against Some(TypeExpr::Map { .. }) without self.resolve_type_alias(&base_ty) and has no Expr::Receive arm for v, ok := <-ch.
Why This Causes a Soundness Bypass (HYB-E3003 & HYB-E3004)
Because shape_may_share(&TypeShape::Unknown) is false (shape.rs:112), when alias := g(m), alias := h.cb(m), alias := sub2[0](m), or alias, ok := p.cb(m) degrades alias's shape to TypeShape::Unknown:
Copying copy_of_alias := alias records no may_share edge from alias to copy_of_alias (loans.rs:1577). Moving m into a concurrent task (task worker(move m, done)) freezes m and alias, while leaving copy_of_alias completely unfrozen to mutate the same underlying map concurrently (HYB-E3003 bypass -> concurrent map write race).
Reassigning escaped = alias (where var escaped map[string]int has a declared Map shape) skips non_owned_origin propagation when alias's shape is Unknown, allowing a borrowed parameter map to be moved into a task via task worker(move escaped, done) (HYB-E3004 bypass).
Activity
fix(hy-check): preserve return shapes and TypeExprs across fn-value c…
fix(hy-check): preserve return shapes and TypeExprs across fn-value c…
fix(hy-check): preserve return shapes and TypeExprs across fn-value c…
dancerdan15 commentedon Oct 23, 2026
/attempt #1042
test(hy-check): add limitlessprojects#1042 regression tests
test(corpus): add limitlessprojects#1042 positive control