Issue #14836 has been updated by yui-knk (Kaneko Yuichiro).


If you use location information of proc to get AST nodes, I feel adding class method to AST module which receives proc and return AST nodes directly is useful.
What do you think about it?

For example:

```ruby
def a(&block)
  node = RubyVM::AST.of(block)
  p node
  p node.children
  p node.children.last.children
end

a do
  1 + 2
  "abc".upcase
end
```

```shell
$ ./miniruby /tmp/of.rb
#<RubyVM::AST::Node(NODE_SCOPE(0) 8:2, 11:3): >
[[], nil, #<RubyVM::AST::Node(NODE_BLOCK(1) 9:2, 10:14): >]
[#<RubyVM::AST::Node(NODE_OPCALL(36) 9:2, 9:7): >, #<RubyVM::AST::Node(NODE_CALL(35) 10:2, 10:14): >]
```

Ref: https://github.com/ruby/ruby/compare/trunk...yui-knk:feature/ast_of?expand=1

----------------------------------------
Feature #14836: Method to return first/last lineno/column of Proc
https://bugs.ruby-lang.org/issues/14836#change-74711

* Author: tagomoris (Satoshi TAGOMORI)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
As written in https://bugs.ruby-lang.org/issues/6012, we want to know column no of Proc location.
In addition to it, I want to know the last_lineno and last_column.

If we don't have these values, we cannot know whether the "a" in code below is defined in block, or not.

```ruby
b1 = ->(){ foo() }; a = 1; b2 = ->(){ bar() }
```




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>