Skip to content

hy-check: resolve [N]T, map[K]V, and option[T] in generic struct field kinds (fixes #3705) - #3706

Merged
limitlessprojects merged 4 commits into
limitlessprojects:mainfrom
dextermos-dev:fix-3705-generic-struct-composite-fields
Nov 5, 2026
Merged

limitlessprojects merged 4 commits into
limitlessprojects:mainfrom
dextermos-dev:fix-3705-generic-struct-composite-fields

Conversation

@dextermos-dev

Copy link
Copy Markdown
Contributor

Fixes #3705

Summary

Resolves Row 13 (BUILDABLE) false-accepts when a generic struct field is instantiated with a fixed-size array ([N]T), map (map[K]V), option (option[T]), or typed scalar container ([]i64, [N]i64, map[K]i64):

  1. Collector::kind_of_type_str: Routes composite type spellings through CompFamily::split (covering [N]T, map[K]V, []T, *T, and chan T) and handles option[T] before falling back to kind_of_named.
  2. Collector::struct_field_container_elem_scalar: Resolves container element/value numeric scalars when the struct field is a generic type parameter (TypeExpr::Named) instantiated with a slice, array, or map.
  3. Collector::map_key_scalar_name & Collector::typed_value_type_name: Extend resolution to Expr::Field so map key scalar width checks (b.val[k64] on box[map[i32]int]) and fixed-size array length comparisons (var a [2]int = b.val on box[[3]int]) work through struct field projections.

Verification

  • Added integration test suite compiler/crates/hy-check/tests/buildable_generic_struct_composite_fields_3705.rs covering all 7 reject cases + valid in-bounds controls.
  • cargo test -p hy-check passes with 0 regressions.

Settlement Rail: USDC on Base Mainnet (Chain ID 8453)
Settlement Wallet: 0x8366bCe3a2D379De7656D7A67015789FaF999f20

@limitlessprojects
limitlessprojects merged commit 9b6b54a into limitlessprojects:main Nov 5, 2026
3 checks passed
@limitlessprojects

Copy link
Copy Markdown
Owner

Landed: 9b6b54a5 — ALL-GREEN, merged with credit

Merged into main as 9b6b54a5f773f9ca8af79d361e1f18daab2e70c3 (trial merge 4a2eb62e, tree 627dc141 asserted identical before commit; remote assertion passed).

What landed

  • kind_of_type_str routes composite spellings through CompFamily::split — the old hand-rolled prefix chain parsed *T/[]T/chan but silently dropped Array and Map spellings to kind_of_named (fail-open Unknown), which is exactly why box[[3]int] / box[map[K]V] field kinds went unchecked. Chan parsing also unified.
  • option[T] spellings now resolve to OpKind::Option instead of falling into named lookup.
  • scalar_of_type_name substitutes type parameters whose bound spelling is a composite and extracts the element/value scalar — so len(b.fields[i])-class operand checks see real scalars.
  • Type-name lookup and map_key_scalar_name accept Field bases via struct_field_type_name.
  • 54-line pin suite buildable_generic_struct_composite_fields_3705.rs.

Verification evidence (four gates on committed trial merge 4a2eb62e)

  1. Merge gate: auto-merge clean against main b8069b31.
  2. cargo test --workspace: 429 suites, 2849 tests, all green (428 → 429).
  3. Corpus harness: 135/135 verdict agreement, tripwire not fired.
  4. Differential FULL: accept-side 45/45 build+run, reject-side 90/90.

Bounty processed per BOUNTY.md via discussion #295. CREDIT: @dextermos-dev — recorded in the merge commit (second landing today, after #3704).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[buildable] hy-check: kind_of_type_str and struct_field_container_elem_scalar drop [N]T, map[K]V, and option[T] on generic struct fields (Row 13)

2 participants