cowboyd/therubyracer — Issue #130: Error when overriden Ruby methods
Author: Zapotek
Created: 2011-12-12 06:16:31+00:00
State: open

# 1st occurrence

Backtrace:

```
/home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/proxies.rb:44:in `[]=': can't convert String into Integer (TypeError)
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/proxies.rb:44:in `register_javascript_proxy'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:23:in `block (2 levels) in initialize'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:98:in `enter'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:21:in `block in initialize'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal.rb:16:in `lock'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:10:in `initialize'
from tmp/error.rb:26:in `new'
from tmp/error.rb:26:in `

'
```

Reproduce with:

```
require 'v8'

class Test
def hello
'world'
end

def hash
'fff'
end

end

js = V8::Context.new( :with => Test.new )

p js.eval( 'hello' )
```

# 2nd occurrence

Same cause, different backtrace:

```
/home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/proxies.rb:52:in `rb_object_2_js_proxy': can't convert String into Integer (TypeError)
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/proxies.rb:29:in `rb2js'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal.rb:80:in `v8'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/caller.rb:26:in `protect'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/interceptors.rb:56:in `intercept'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal/interceptors.rb:68:in `call'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:45:in `Run'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:45:in `block (3 levels) in eval'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:98:in `enter'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:40:in `block (2 levels) in eval'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:39:in `try'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:39:in `block in eval'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/portal.rb:16:in `lock'
from /home/zapotek/.rvm/gems/ruby-1.9.3-p0/gems/therubyracer-0.9.9/lib/v8/context.rb:38:in `eval'
from tmp/error.rb:22:in `

'
```

Reproduce with:

```
require 'v8'

class HashContainer
def hash
'blah'
end

def bar
'dd'
end
end

class Test
attr_accessor :blah
def initialize
@blah = ::HashContainer.new
end
end

js = V8::Context.new( :with => Test.new )

p js.eval( 'blah.bar' )

```