Skip to content

Honor exception: false for complex conversion - #549

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/honor-complex-exception-false
Open

Honor exception: false for complex conversion#549
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/honor-complex-exception-false

Conversation

@OskarEichler

Copy link
Copy Markdown

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.

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.

1 participant