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
hy-check(shape): named_shape_depth and call_shape omit complex64 and complex128, falsely rejecting sendable values with HYB-E3005 #4000
Under SPEC §9.2 and GUARANTEES.md (SENDABILITY & SPAWN-BOUNDARIES), primitive copy-by-value numeric types are unconditionally sendable across tasks and channel boundaries (O4).
However, in compiler/crates/hy-check/src/shape.rs:
Checker::named_shape_depth enumerates primitive types (int, i8, ..., float32, float64, bool, byte, rune) but omits complex64, complex128, c64, and c128. Consequently, basic complex numbers resolve to TypeShape::Unknown.
Checker::call_shape resolves built-in constructor/conversion shapes for primitives (int, uint, float32, float64), but omits complex64, complex128, complex, real, and imag, returning TypeShape::Unknown for c := complex(1.0, 2.0).
Checker::receiver_type_params omits complex64 and complex128 from its non-param filter list.
Because sendability.rs enforces fail-closed boundary checking on unproven shapes (O4.9), passing any complex value (or a struct with complex fields like struct Signal { freq complex128 }) to a task spawn (task worker(c)) or channel send (ch <- c) fails compilation with: HYB-E3005: value cannot cross task/send boundary because its type did not resolve to a sendability class
falsely rejecting valid, memory-safe concurrent programs.
fn main() {
var c complex128
task worker(c) // rejects with HYB-E3005
var s Signal
task struct_worker(s) // rejects with HYB-E3005
ch := make(chan complex128, 1)
ch <- c // rejects with HYB-E3005
}
`
Fix & Verification
Added complex64, complex128, c64, and c128 to TypeShape::Primitive in named_shape_depth.
Added complex64, complex128, complex, real, and imag to TypeShape::Primitive in call_shape.
Added complex64 and complex128 to receiver_type_params.
Added comprehensive regression test suite compiler/crates/hy-check/tests/shape_complex_primitive_sendability.rs covering bare complex values, struct fields, and channel sends.
Settlement Coordinates:
Author: @bradwue313
Base USDC: 0x38e0f40371be8b30f0909f890a1f701a25cd30cd
Under SPEC §9.2, complex64 and complex128 (along with aliases c64 and c128) are primitive copy-by-value numeric types and must be classified as unconditionally sendable (TypeShape::Primitive).
The hy-check shape analysis pass fails to register complex primitive types across three helper methods in compiler/crates/hy-check/src/shape.rs:
Checker::named_shape_depth: Omits complex64, complex128, c64, and c128 from primitive type string matching, defaulting named type shapes to TypeShape::Unknown.
Checker::call_shape: Omits constructor invocations for complex64, complex128, as well as built-in functions complex, real, and imag, returning TypeShape::Unknown for built-in expressions.
Checker::receiver_type_params: Omits complex64 and complex128 from the primitive non-generic filter set.
Because sendability.rs enforces rule O4.9 (fail-closed on TypeShape::Unknown), any complex scalar, struct embedding complex fields, or channel carrying complex types is classified as unproven, triggering a false-positive compilation failure with HYB-E3005.
To prevent future regression of primitive scalar sendability boundaries, add compiler/crates/hy-check/tests/shape_complex_primitive_sendability.rs covering shape derivation and boundary crossing:
Direct Scalar Sendability: Spawning a task with complex64 and complex128 arguments.
Built-in Expression Shapes: Passing results of complex(r, i), real(c), and imag(c) across task boundaries.
Composite Struct Shapes: Defining a struct with nested complex fields (e.g., struct Signal { freq complex128 }) and verifying that TypeShape::Struct derives Sendable without unknown fields.
Channel Boundary Verification: Instantiating chan complex128 and ensuring send (ch <- c) and receive operations resolve properly under rule O4.
Under SPEC §9.2 and GUARANTEES.md (O4), primitive scalar types are strictly value-copied across isolation domains and must evaluate to TypeShape::Primitive during semantic shape analysis.
In compiler/crates/hy-check/src/shape.rs, complex number primitive identifiers (complex64, complex128) and their shorthand aliases (c64, c128), along with complex numeric built-in calls (complex, real, imag), were missing from pattern matches across three key routines:
Checker::named_shape_depth: Resolved primitive type names to shapes. The absence of complex primitives caused type shape resolution to yield TypeShape::Unknown.
Checker::call_shape: Resolved expression shapes for primitive cast and factory built-in functions. The missing cases evaluated constructor expressions like complex(re, im) to TypeShape::Unknown.
Checker::receiver_type_params: Handled non-generic receiver type filtering. Missing complex types permitted unintended generic parameter checks or misclassifications.
When sendability.rs checks values against spawn or channel transfer boundaries, unproven or unresolved shapes fall through to the fail-closed defense mechanism (O4.9), triggering HYB-E3005.
Activity
dukenordj-rgb commentedon Nov 7, 2026
Root Cause Analysis
Under SPEC §9.2,
complex64andcomplex128(along with aliasesc64andc128) are primitive copy-by-value numeric types and must be classified as unconditionally sendable (TypeShape::Primitive).The
hy-checkshape analysis pass fails to register complex primitive types across three helper methods incompiler/crates/hy-check/src/shape.rs:Checker::named_shape_depth: Omitscomplex64,complex128,c64, andc128from primitive type string matching, defaulting named type shapes toTypeShape::Unknown.Checker::call_shape: Omits constructor invocations forcomplex64,complex128, as well as built-in functionscomplex,real, andimag, returningTypeShape::Unknownfor built-in expressions.Checker::receiver_type_params: Omitscomplex64andcomplex128from the primitive non-generic filter set.Because
sendability.rsenforces ruleO4.9(fail-closed onTypeShape::Unknown), any complex scalar, struct embedding complex fields, or channel carrying complex types is classified as unproven, triggering a false-positive compilation failure withHYB-E3005.Patch Snippet
Verification & Regression Coverage
To prevent future regression of primitive scalar sendability boundaries, add
compiler/crates/hy-check/tests/shape_complex_primitive_sendability.rscovering shape derivation and boundary crossing:taskwithcomplex64andcomplex128arguments.complex(r, i),real(c), andimag(c)across task boundaries.struct Signal { freq complex128 }) and verifying thatTypeShape::StructderivesSendablewithout unknown fields.chan complex128and ensuring send (ch <- c) and receive operations resolve properly under ruleO4.dukenordj-rgb commentedon Nov 7, 2026
Root Cause Analysis
Under SPEC §9.2 and GUARANTEES.md (O4), primitive scalar types are strictly value-copied across isolation domains and must evaluate to
TypeShape::Primitiveduring semantic shape analysis.In
compiler/crates/hy-check/src/shape.rs, complex number primitive identifiers (complex64,complex128) and their shorthand aliases (c64,c128), along with complex numeric built-in calls (complex,real,imag), were missing from pattern matches across three key routines:Checker::named_shape_depth: Resolved primitive type names to shapes. The absence of complex primitives caused type shape resolution to yieldTypeShape::Unknown.Checker::call_shape: Resolved expression shapes for primitive cast and factory built-in functions. The missing cases evaluated constructor expressions likecomplex(re, im)toTypeShape::Unknown.Checker::receiver_type_params: Handled non-generic receiver type filtering. Missing complex types permitted unintended generic parameter checks or misclassifications.When
sendability.rschecks values against spawn or channel transfer boundaries, unproven or unresolved shapes fall through to the fail-closed defense mechanism (O4.9), triggeringHYB-E3005.Patch Solution
Regression Testing Strategy
Add an integration test target at
compiler/crates/hy-check/tests/shape_complex_primitive_sendability.rs: