Repository navigation
fix(hy-check): reject typed int variables in float var declarations and mismatched copy slice elements (fixes #2560) - #2589
Open
Dimank92 wants to merge 1 commit into
Conversation
This was referenced Nov 1, 2026
Dimank92
force-pushed
the
fix/issue-2560-float-var-decl-and-copy-slice-soundness
branch
from
November 1, 2026 14:31
73a90b2 to
1604052
Compare
Contributor
Author
|
Rebased cleanly onto current
Bounty claim: |
Dimank92
force-pushed
the
fix/issue-2560-float-var-decl-and-copy-slice-soundness
branch
from
November 1, 2026 15:17
1604052 to
f3546b1
Compare
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
Fixes #2560, fixes #2538.
This PR addresses soundness issues in
hy-checkwhere typedintvariables bypassed type checking when initializingfloat64variable declarations, and where built-incopy(dst, src)erroneously accepted slice arguments with mismatched element types (e.g.[]float64and[]int).Soundness Analysis & Defect Resolution
Typed Variable Initialization (
var/let):Collector::local,kinds_conflict(&want, &vk)previously allowed typed integer variables to initializefloat64variables becausekinds_conflict(Float, Int)returnsfalseto permit untyped constants.int_float_conflict = want == OpKind::Float && vk == OpKind::Int && !self.is_untyped_int_const(expr).float64variable with a typedintvariable (var i int = 1; var f float64 = i) is now strictly rejected withHYB-E1002.Built-in
copy(dst, src)Slices Element Type Matching:check_builtin_operand_kindsunder"copy",kinds_conflict(dst_elem, src_elem)previously permitted copying between[]float64and[]int.dst_elem == src_elem(unless either isOpKind::Unknown), rejecting mismatched slice copies withHYB-E1002.Untyped vs Typed Constants:
1,const k = 1; var f float64 = k,k + 1) remain legal and accepted per the Go specification.is_untypedonDefineandfile_untyped_constsonCollector, typed constants (const k int = 1; var f float64 = k) are properly rejected withHYB-E1002.Verification
compiler/crates/hy-check/tests/var_init_and_copy_slice_soundness.rs:single_var_init_typed_int_to_float_is_rejectedlet_init_typed_int_to_float_is_rejectedcopy_slice_mismatched_float_and_int_is_rejecteduntyped_int_constants_in_float_var_init_acceptedtyped_int_constants_in_float_var_init_rejected