Skip to content

hy-check(buildable): validate operand types and float widths for complex, real, and imag builtins (fixes #2896) - #4194

Open
SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix/complex-real-imag-soundness
Open

SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix/complex-real-imag-soundness

Conversation

@SuperPiIot

@SuperPiIot SuperPiIot commented Nov 8, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2896 under GUARANTEES.md Row 13 (BUILDABLE):
Under the Go specification (§Complex numbers):

  1. complex(r, i) requires both operands to be floating-point numbers of identical type (float32 or float64).
  2. complex(r, i) rejects typed integers (int32, int64, etc.) and mismatched float widths (float32 vs float64).
  3. real(c) and imag(c) require the operand to be a complex number (complex64 or complex128).
  4. real(c) and imag(c) reject non-complex numbers (float32, float64, int32, int, etc.).

Changes

  • In compiler/crates/hy-check/src/buildable.rs:
    • Added complex scalar propagation to call_result_scalars for complex, real, and imag.
    • Extended check_builtin_operand_kinds to validate scalar types for real and imag, rejecting non-complex arguments (float32, float64, int32, etc.) with HYB-E1002.
    • Extended check_builtin_operand_kinds for complex to reject non-float arguments (int32, int64, etc.) and enforce that both operands have matching floating-point widths (float32 vs float64) with HYB-E1002.
  • Added comprehensive integration test suite compiler/crates/hy-check/tests/complex_scalars_operand_soundness.rs (13/13 tests passing).
  • Verified zero regressions across hy-check unit test suite (183/183 passing) and differential 135-corpus (90/90 reject agreement).

Fixes #2896

Settlement Coordinates

  • Network: Base Mainnet (Chain ID 8453)
  • Asset: USDC
  • Wallet: 0xf084cF0076F91AA48C2370F427C399dAA8C1f07F

@github-actions github-actions Bot added the bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) label Nov 8, 2026
@SuperPiIot
SuperPiIot force-pushed the fix/complex-real-imag-soundness branch 2 times, most recently from 8c311f5 to b79a3eb Compare November 9, 2026 01:33
@github-actions github-actions Bot added the bot:stale-base Shepherd: behind main beyond threshold label Nov 9, 2026
@SuperPiIot
SuperPiIot force-pushed the fix/complex-real-imag-soundness branch 2 times, most recently from 7fa41a5 to 88df5ea Compare November 9, 2026 23:39
@SuperPiIot
SuperPiIot force-pushed the fix/complex-real-imag-soundness branch from 88df5ea to e43e26b Compare November 10, 2026 01:16
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.

Soundness: built-in complex, real, and imag allow invalid operand types and mismatched scalars

1 participant