ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nagachika (Tomoyuki Chikanaga)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110614] [Ruby master Bug#19004] Complex can be nested by Complex.polar
Date: Sat, 05 Nov 2022 05:25:20 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-99946.20221105052519.18236@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19004.20220910174614.18236@ruby-lang.org

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/

      parent reply	other threads:[~2022-11-05  5:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-10 17:46 [ruby-core:109879] [Ruby master Bug#19004] Complex can be nested by Complex.polar msnm (Masahiro Nomoto)
2022-10-16 19:55 ` [ruby-core:110322] " stevegeek (Stephen Ierodiaconou)
2022-11-05  5:25 ` nagachika (Tomoyuki Chikanaga) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-99946.20221105052519.18236@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=ruby-core@neon.ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).