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: unify_param_with_arg_shape skips compound generic struct type args (box[[]t], box[*t]), bypassing HYB-E3001 and HYB-E3003 #3948
In Checker::unify_param_with_arg_shape (compiler/crates/hy-check/src/shape.rs:1868-1884), when a generic function parameter is a generic struct instantiated with a compound type argument that mentions a type parameter t (such as b box[[]t], b box[[1]t], b box[*t], b box[option[t]], b box[map[string]t], or b box[inner[t]]), line 1875 checks if tparams.contains(pa.as_str()). Because pa is "[]t" rather than "t", unification is skipped and subst remains empty.
If the file also defines a package-level type or alias named t (e.g., type t = int or struct t { n int }, which is legal in Go because [t any] on fn first_elem[t](b box[[]t]) t shadows the package-level t), shape_of_type_with_subst falls back to named_shape_depth("t") and classifies the return value of first_elem(b) as TypeShape::Primitive (int) instead of TypeShape::Map(...).
This allows:
Passing first_elem(b) directly to task worker(first_elem(b), done) without move (HYB-E3001 bypass).
Storing alias := first_elem(b) without recording a may_share edge, then moving m via task worker(move m, done) while mutating alias["main"] = 2 concurrently (HYB-E3003 bypass).
type t = int
struct box[u] {
val u
}
fn first_elem[t](b box[[]t]) t {
return b.val[0]
}
fn worker(m map[string]int, done chan int) {
m["worker"] = 1
done <- 1
}
fn main() {
m := map[string]int{"init": 0}
b := box[[]map[string]int]{val: []map[string]int{m}}
done := make(chan int, 1)
task worker(first_elem(b), done)
m["main"] = 2
<-done
}
Expected:Verdict::Reject with HYB-E3001 (first_elem(b) returns a map[string]int shared with m and is spawned into task worker without move).
Actual:Verdict::Accept (0 diagnostics).
Fix
Add recursive type-argument string unification (unify_param_str_with_arg_shape) in compiler/crates/hy-check/src/shape.rs so compound generic type arguments ([]t, [N]t, *t, option[t], map[k]v, nested inner[t]) inside TypeExpr::Named unify t against the corresponding inner TypeShape.
In fn_call_shape_subst, default any remaining unresolved type parameter in tparam_set to TypeShape::Unknown so shape_of_type_with_subst never resolves an active type parameter against a shadowed package-level type of the same name.
Payout Wallet (Base USDC)
Base / EVM (USDC):0x8132B258bC02F98EbcE321EFf18528938fB58940
Updated original reporter PR #3949 (#3949) per @limitlessprojects review (using raw string literals r#...# in soundness_closure_scoped_moves_and_compound_generic.rs).
Activity
CrowAleksito commentedon Nov 7, 2026
Fix PR opened by original reporter (@CrowAleksito): #3949 — Official Base USDC wallet:
0x8132B258bC02F98EbcE321EFf18528938fB58940hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
zongsm-cmyk commentedon Nov 7, 2026
Submitted clean fix with raw string test fixtures in PR #4056 (#4056).
shape.rs(unify_param_str_with_arg_shape).st.closure_scoped_envsdual-write infreeze.rsandmodel.rsfor block-scoped bindings.r#"..."#socargo test --workspacecompiles cleanly without literal token collisions.Closes #3947
Closes #3948
/claim #3948
Base (USDC) Payout Address:
0xC10373008eFb38192C87C375ac63aB12E27C684Chy-check(shape): recursively unify compound generic struct type argum…
test(hy-check): use raw string literals and [t any] in limitlessproje…
CrowAleksito commentedon Nov 7, 2026
Updated original reporter PR #3949 (#3949) per @limitlessprojects review (using raw string literals
r#...#insoundness_closure_scoped_moves_and_compound_generic.rs).hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
hy-check(shape): recursively unify compound generic struct type argum…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): propagate block-scoped moves to closure_scoped_envs an…
fix(hy-check): unify compound generic struct type args in unify_param…