mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[Bug #19004] `Complex.polar` handles complex singular `abs` argument `Complex.polar` accepts Complex values as arguments for the polar form as long as the value of the complex has no imaginary part (ie it is 'real'). In `f_complex_polar` this is handled by extracting the real part of the arguments. However in the case `polar` is called with only a single argument, the absolute value (abs), then the Complex is created without applying a check on the type of abs, meaning it is possible to create a Complex where the real part is itself an instance of a Complex. This change removes the short circuit for the single argument case meaning the real part extraction is performed correctly (by f_complex_polar). Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that the real part of a complex argument is correctly extracted and used in the resulting Complex real and imaginary parts. --- complex.c | 13 ++++++------- spec/ruby/core/complex/polar_spec.rb | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) |
||
|---|---|---|
| .. | ||
| argf | ||
| array | ||
| basicobject | ||
| binding | ||
| builtin_constants | ||
| class | ||
| comparable | ||
| complex | ||
| conditionvariable | ||
| data | ||
| dir | ||
| encoding | ||
| enumerable | ||
| enumerator | ||
| env | ||
| exception | ||
| false | ||
| fiber | ||
| file | ||
| filetest | ||
| float | ||
| gc | ||
| hash | ||
| integer | ||
| io | ||
| kernel | ||
| main | ||
| marshal | ||
| matchdata | ||
| math | ||
| method | ||
| module | ||
| mutex | ||
| nil | ||
| numeric | ||
| objectspace | ||
| proc | ||
| process | ||
| queue | ||
| random | ||
| range | ||
| rational | ||
| regexp | ||
| signal | ||
| sizedqueue | ||
| string | ||
| struct | ||
| symbol | ||
| systemexit | ||
| thread | ||
| threadgroup | ||
| time | ||
| tracepoint | ||
| true | ||
| unboundmethod | ||
| warning | ||