Repository navigation
fix(hy-check): reject container element, key, value, base, and array alias mismatches in var and let declarations (fixes #3448) - #3468
Open
seenorht wants to merge 1 commit into
Conversation
Contributor
Author
|
Settlement wallet (Base USDC): |
seenorht
force-pushed
the
fix/issue-3448-var-decl-container-soundness
branch
28 times, most recently
from
November 4, 2026 18:25
8e4156f to
53dd1a8
Compare
seenorht
force-pushed
the
fix/issue-3448-var-decl-container-soundness
branch
29 times, most recently
from
November 6, 2026 21:17
70ddd36 to
7ff945e
Compare
…alias mismatches in var and let declarations (fixes limitlessprojects#3448)
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.
Fixes #3448.
1. Summary
Under Go specification (§Variable declarations, §Assignability) and Go-Hybrid's Row 13 (
BUILDABLE) soundness guarantee:varorlet) requires that initialized expressions match the declared type.var c chan int32 = ch64(wherech64 chan int64) ->cannot use ch64 (variable of type chan int64) as chan int32 value in variable declarationvar m map[string]int32 = m64(wherem64 map[string]int64) ->cannot use m64 as map[string]int32var s []int32 = s64(wheres64 []int64) ->cannot use s64 as []int32var p *int32 = p64(wherep64 *int64) ->cannot use p64 as *int32var a arr32 = a64(wheretype arr32 = [32]byte,type arr64 = [64]byte) ->cannot use a64 as arr32Prior to this fix,
kinds_conflictcollapsed these types into coarse kinds (Chan(Int),Map(Str, Int),Slice(Int),Pointer(Int)), whilescalar_of_tyandsized_array_names_differonly checked bare scalars and syntactic sized arrays ([3]int), letting mismatched container and alias declarations passhyb checkwith 0 diagnostics and failgo build.2. Surgical Fix
In
compiler/crates/hy-check/src/buildable.rs:resolve_type_str: iteratively unfolds type aliases up to 10 depths usingself.ck.type_aliases.container_type_names_conflict: strictly detects element/key/value/base mismatches across channels (chan,chan<-,<-chan), maps, slices, pointers, and array aliases without disturbing array composite literals or[...]Tinferences.fn localfor both single and multi-variable declarations (varandlet), emittingHYB-E1002.3. Test Coverage
compiler/crates/hy-check/tests/issue_3448_var_decl_container_soundness.rs:test_var_decl_chan_element_mismatch: rejectsvar c chan int32 = ch64withHYB-E1002.test_var_decl_map_value_mismatch: rejectsvar m map[string]int32 = m64withHYB-E1002.test_var_decl_map_key_mismatch: rejectsvar m map[int32]string = m64withHYB-E1002.test_var_decl_slice_element_mismatch: rejectsvar s []int32 = s64withHYB-E1002.test_var_decl_pointer_base_mismatch: rejectsvar p *int32 = p64withHYB-E1002.test_var_decl_array_alias_mismatch: rejectsvar a arr32 = a64withHYB-E1002.test_let_decl_container_mismatches: rejectsletcontainer mismatches.test_var_decl_containers_valid_controls: verifies valid channels, maps, slices, pointers, and array aliases accept cleanly.[3]string{"a"}and[...]string{"a"}).tools/check_guarantees.py: OK.tools/check_test_registration.py: OK.tools/check_conflict_markers.py: OK.Bounty payout rail: USDC on Base
Recipient settlement: Registered under contributor @seenorht (per BOUNTY.md and Discussion #295)