Project

General

Profile

Actions

Bug #22020

open

Inner call node without all arguments returned by RubyVM::AbstractSyntaxTree.of for call with a block

Bug #22020: Inner call node without all arguments returned by RubyVM::AbstractSyntaxTree.of for call with a block

Added by Eregon (Benoit Daloze) about 2 months ago. Updated about 2 months ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.1.0dev
[ruby-core:125396]

Description

begin
  foo(1, 2, kw: :arg) { 42 }
rescue => e
  pp RubyVM::AbstractSyntaxTree.of e.backtrace_locations[0]
end
$ ruby --parser=parse.y rubyvm_ast_node_id_loc.rb
(FCALL@2:2-2:21 :foo
   (LIST@2:6-2:20 (INTEGER@2:6-2:7 1) (INTEGER@2:9-2:10 2)
      (HASH@2:12-2:20 (LIST@2:12-2:20 (SYM@2:12-2:15 :kw) (SYM@2:16-2:20 :arg) nil)) nil))

That covers foo(1, 2, kw: :arg) so all arguments except the block argument, which looks inconsistent.

I believe it should be:

$ ruby --parser=parse.y rubyvm_ast_node_id_loc.rb
(ITER@2:2-2:28
   (FCALL@2:2-2:21 :foo
      (LIST@2:6-2:20 (INTEGER@2:6-2:7 1) (INTEGER@2:9-2:10 2)
         (HASH@2:12-2:20 (LIST@2:12-2:20 (SYM@2:12-2:15 :kw) (SYM@2:16-2:20 :arg) nil)) nil))
   (SCOPE@2:22-2:28 tbl: [] args: nil body: (INTEGER@2:24-2:26 42)))

which covers foo(1, 2, kw: :arg) { 42 }.

PR: https://github.com/ruby/ruby/pull/16836

Actions

Also available in: PDF Atom