ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "msnm (Masahiro Nomoto)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:109879] [Ruby master Bug#19004] Complex can be nested by Complex.polar
Date: Sat, 10 Sep 2022 17:46:15 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-19004.20220910174614.18236@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19004.20220910174614.18236@ruby-lang.org

Issue #19004 has been reported by msnm (Masahiro Nomoto).

----------------------------------------
Bug #19004: Complex can be nested by Complex.polar
https://bugs.ruby-lang.org/issues/19004

* Author: msnm (Masahiro Nomoto)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.2
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`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/

       reply	other threads:[~2022-09-10 17:46 UTC|newest]

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

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.issue-19004.20220910174614.18236@ruby-lang.org \
    --to=ruby-core@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).