Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex() Kernel method does not consult an object's to_c method #4483

Closed
janlelis opened this issue Feb 7, 2017 · 0 comments
Closed

Complex() Kernel method does not consult an object's to_c method #4483

janlelis opened this issue Feb 7, 2017 · 0 comments

Comments

@janlelis
Copy link

@janlelis janlelis commented Feb 7, 2017

Environment

  • ruby -v jruby 9.1.8.0-SNAPSHOT (2.3.1) 2017-02-06 3f97c7a Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +indy +jit [linux-x86_64]
  • uname -a Linux ok 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Test Case

complex.rb:

o = Object.new
def o.to_c
  1i  
end

p Complex(o)

Expected Behavior

  • Should print: (0+1i)

Actual Behavior

  • Throws error:
TypeError: not a real
     rect at org/jruby/RubyComplex.java:356
  convert at org/jruby/RubyComplex.java:435
  Complex at org/jruby/RubyKernel.java:357
   <main> at complex.rb:6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.