ruby-changes:62981
From: Kenta <ko1@a...>
Date: Wed, 16 Sep 2020 19:27:33 +0900 (JST)
Subject: [ruby-changes:62981] 68b5f14d53 (master): Fix assertion failed in Complex.polar without NDEBUG (#3551)
https://git.ruby-lang.org/ruby.git/commit/?id=68b5f14d53 From 68b5f14d536c1a81c63412a9f3701380c9bc116c Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@u...> Date: Wed, 16 Sep 2020 19:27:16 +0900 Subject: Fix assertion failed in Complex.polar without NDEBUG (#3551) Fixes [Bug #17172]. diff --git a/complex.c b/complex.c index b8dd616..4100fac 100644 --- a/complex.c +++ b/complex.c @@ -732,6 +732,14 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/complex.c#L732 nucomp_real_check(arg); break; } + if (RB_TYPE_P(abs, T_COMPLEX)) { + get_dat1(abs); + abs = dat->real; + } + if (RB_TYPE_P(arg, T_COMPLEX)) { + get_dat1(arg); + arg = dat->real; + } return f_complex_polar(klass, abs, arg); } diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index a4fe9d4..a3a7546 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -220,6 +220,11 @@ class Complex_Test < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_complex.rb#L220 def test_polar assert_equal([1,2], Complex.polar(1,2).polar) assert_equal(Complex.polar(1.0, Math::PI * 2 / 3), Complex.polar(1, Math::PI * 2 / 3)) + + assert_in_out_err([], <<-'end;', ['OK'], []) + Complex.polar(1, Complex(1, 0)) + puts :OK + end; end def test_uplus -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/