Skip to content

Honor exception: false for complex conversion - #549

Merged
tompng merged 2 commits into
ruby:masterfrom
OskarEichler:codex/honor-complex-exception-false
Sep 12, 2026
Merged

Honor exception: false for complex conversion#549
tompng merged 2 commits into
ruby:masterfrom
OskarEichler:codex/honor-complex-exception-false

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

  • return nil for Complex values with a nonzero imaginary part when exception: false
  • preserve ArgumentError for the default and exception: true paths

Why:
Kernel.BigDecimal accepts exception: false as a non-raising conversion mode, but this Complex branch contains a TODO and always raises. That differs from the documented option and the method’s other invalid-input paths.

Verification:

  • baseline reproduction raises ArgumentError for BigDecimal(Complex(1, 1), exception: false)
  • fixed reproduction returns nil; exception: true still raises; zero-imaginary conversion is unchanged
  • full current suite: 266 tests, 13,616 assertions, 0 failures/errors/omissions
  • RBS suite: 146 tests, 1,805 assertions, 0 failures/errors

Compatibility:
Only the explicitly non-raising invalid-conversion path changes.

@tompng
tompng merged commit 0d5a486 into ruby:master Sep 12, 2026
83 checks passed
@tompng tompng added the bug label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants