Skip to content

fix: binop width selection to preserve byte semantics [LA-D]#370

Open
rose2221 wants to merge 1 commit intomainfrom
rs/issue_d
Open

fix: binop width selection to preserve byte semantics [LA-D]#370
rose2221 wants to merge 1 commit intomainfrom
rs/issue_d

Conversation

@rose2221
Copy link
Copy Markdown
Collaborator

Summary

  • Restricted get_optimal_binop_width to only return widths that divide 8 ({2, 4, 8}) instead of the full range [2, 8]. Non-dividing widths (e.g. 3, 5, 6, 7) cause digit decompositions that overallocate bit capacity beyond [0, 255], breaking byte semantics.
  • Added unit tests for the binop module:
    • optimal_binop_width_always_divides_8: verifies the width invariant holds for all input sizes up to 1024.
    • non_canonical_byte_rejected_by_recomposition: regression test confirming that the recomposition constraint rejects non-canonical byte values (> 255) when using w ∈ {2, 4}.

@rose2221 rose2221 changed the title fix: binop width selection to preserve byte semantics fix: binop width selection to preserve byte semantics [LA-D] Mar 22, 2026
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert this debug_assert! to assert! and update the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants