opal/opal — pull request #551 by yhara (2014-06-16 08:18:24+00:00)
Title: Fix String#to_proc

This PR fixes this code raises "NoMethodError: undefined method `last' for 1".

```rb
[[1,2],[3,4]].map(&:last)
```
Link: http://opalrb.org/try/#code:%5B%5B1%2C2%5D%2C%5B3%2C4%5D%5D.map(%26%3Alast)%0A%0A%0A

This implementation is same as [Symbol#to_proc in Rubinius](https://github.com/rubinius/rubinius/blob/d17c1294e09ab9c70495a1278450c09e38ed01c6/kernel/common/symbol.rb#L108-L120) (which looks like [sym_call in MRI](https://github.com/ruby/ruby/blob/800c7af73ccae7ef862674f682d1d82ba2149379/string.c#L8455-L8505)).

--
Sorry this PR does not have a test (I don't know where to add). Simple example:

```rb
[[1,2],[3,4]].map(&:last) #=> should be [2,4]
```

More complex example (calling block with block):

```rb
class Foo
def bar(a, &b)
b.call(a)
end
end

def test(&block)
block.call(Foo.new, 1){|x| puts "I got #{x}" }
end

test(&:bar) #=> should be "I got 1"
```