Skip to content

fix(hy-emit): infer comparable constraint in select headers, places, and array lengths (fixes #2127) - #2134

Open
jpereyra243-byte wants to merge 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix/comparable-inference-select-places-lengths
Open

jpereyra243-byte wants to merge 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix/comparable-inference-select-places-lengths

Conversation

@jpereyra243-byte

Copy link
Copy Markdown

Summary

In compiler/crates/hy-emit/src/lib.rs, generic type parameter inference for Go's comparable constraint (collect_comparable_in_ty / collect_comparable_in_stmt) skipped three AST positions where map[k]v or set[k] expressions can appear:

  1. SelectArmKind::Send (chan and value) and SelectArmKind::Recv (chan) header expressions inside Stmt::Select.
  2. Target places (PlaceKind::Index, PlaceKind::Field, PlaceKind::AddrOf) in Stmt::Assign via collect_comparable_in_place.
  3. Array length expressions (len: Option<Box<Expr>>) in TypeExpr::Array.

When generic parameter k appeared as a key only in those sites, hy-emit emitted func fn_name[k any] instead of [k comparable], leading to go build failure invalid map key type k (missing comparable constraint) (Row 13 BUILDABLE violation).

Fixes #2127.

Changes

  • Added collect_comparable_in_place in compiler/crates/hy-emit/src/lib.rs to inspect indexes and projections in assignment targets.
  • Inspected targets in Stmt::Assign using collect_comparable_in_place.
  • Inspected send/recv expressions in Stmt::Select arm headers.
  • Inspected len in TypeExpr::Array.
  • Added regression test compiler/crates/hy-emit/tests/comparable_inference_select_places_lengths.rs.

Settlement / Payout Wallet (Polygon / USDC): 0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

@github-actions github-actions Bot added the bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify())

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[buildable] hy-emit: generic comparable inference skips select arm headers, assign target places, and array lengths

1 participant