Skip to content

hy-emit: infer comparable constraint in select arms, assign targets, and array lengths - #2133

Open
comandanto wants to merge 1 commit into
limitlessprojects:mainfrom
comandanto:fix/generic-comparable-select-assign-array-2127
Open

comandanto wants to merge 1 commit into
limitlessprojects:mainfrom
comandanto:fix/generic-comparable-select-assign-array-2127

Conversation

@comandanto

Copy link
Copy Markdown

Summary

In compiler/crates/hy-emit/src/lib.rs, generic comparable constraint inference previously omitted three AST positions that can contain map/set expressions over type parameters:

  1. Stmt::Select: arms previously only recursed into &a.body. We now inspect SelectArmKind::Send { chan, value, .. } and SelectArmKind::Recv { chan, .. } header expressions so map keys in send/recv channels or payloads mark the type parameter as comparable.
  2. Stmt::Assign: targets previously were not inspected. We add Emitter::collect_comparable_in_place to traverse index expressions (xs[len(map[k]int{...})] = ...), fields, and address-of places.
  3. TypeExpr::Array: array lengths (len: Option<Box<Expr>>) were omitted. We now traverse len with collect_comparable_in_expr.

When type parameters appear only in those locations, hy-emit now correctly emits [k comparable] instead of [k any], ensuring go build succeeds under GUARANTEES.md Row 13 (BUILDABLE).

Verification

  • Added regression tests in compiler/crates/hy-emit/tests/comparable_inference_issue_2127.rs covering select send/recv, assign index places, and array length expressions in locals and struct fields.
  • Ran all existing hy-emit unit and integration tests (188+ tests pass).
  • Ran python tools/check_test_registration.py (32 test files, 29 patterns: OK).
  • Ran python tools/check_conflict_markers.py --root . (clean).

Closes #2127

@github-actions github-actions Bot added bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) bot:stale-base Shepherd: behind main beyond threshold labels 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()) bot:stale-base Shepherd: behind main beyond threshold

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