From: "nagachika (Tomoyuki Chikanaga)" Date: 2022-11-05T05:25:20+00:00 Subject: [ruby-core:110614] [Ruby master Bug#19004] Complex can be nested by Complex.polar Issue #19004 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE ruby_3_1 597ce7966c38e4f7fc7368a860ac2d056de794ba merged revision(s) 54cad3123a07583c90e85bcfc55ebd87124c1250. ---------------------------------------- Bug #19004: Complex can be nested by Complex.polar https://bugs.ruby-lang.org/issues/19004#change-99946 * Author: msnm (Masahiro Nomoto) * Status: Closed * Priority: Normal * ruby -v: 3.1.2 * Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE ---------------------------------------- `Complex.polar` with one argument can return a "nested" Complex instance, whose real part is also a Complex one. ```ruby puts RUBY_DESCRIPTION # ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] p Complex.polar(1+0i) # ((1+0i)+0i) p 5.times.inject(1) { |num, _| Complex.polar(num) } # (((((1+0i)+0i)+0i)+0i)+0i) ``` In Ruby < 2.7 , it simply raises an error when the argument is an instance of Complex (i.e. `obj.real? == false`). ```ruby puts RUBY_DESCRIPTION # ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux] p Complex.polar(1+0i) # TypeError (not a real) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: