Repository navigation
hy-emit: infer comparable constraint in select arms, assign targets, and array lengths - #2133
Open
comandanto wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
compiler/crates/hy-emit/src/lib.rs, genericcomparableconstraint inference previously omitted three AST positions that can contain map/set expressions over type parameters:Stmt::Select: arms previously only recursed into&a.body. We now inspectSelectArmKind::Send { chan, value, .. }andSelectArmKind::Recv { chan, .. }header expressions so map keys in send/recv channels or payloads mark the type parameter ascomparable.Stmt::Assign: targets previously were not inspected. We addEmitter::collect_comparable_in_placeto traverse index expressions (xs[len(map[k]int{...})] = ...), fields, and address-of places.TypeExpr::Array: array lengths (len: Option<Box<Expr>>) were omitted. We now traverselenwithcollect_comparable_in_expr.When type parameters appear only in those locations,
hy-emitnow correctly emits[k comparable]instead of[k any], ensuringgo buildsucceeds under GUARANTEES.md Row 13 (BUILDABLE).Verification
compiler/crates/hy-emit/tests/comparable_inference_issue_2127.rscovering select send/recv, assign index places, and array length expressions in locals and struct fields.hy-emitunit and integration tests (188+ tests pass).python tools/check_test_registration.py(32 test files, 29 patterns: OK).python tools/check_conflict_markers.py --root .(clean).Closes #2127