Project

General

Profile

Actions

Bug #21983

open

RubyVM::AST no way to find &nil

Bug #21983: RubyVM::AST no way to find &nil

Added by kddnewton (Kevin Newton) about 7 hours ago. Updated about 6 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:125203]

Description

$ ./ruby -e 'pp RubyVM::AbstractSyntaxTree.parse("def foo(&nil); end")'
(SCOPE@1:0-1:18
 tbl: []
 args: nil
 body: (DEFN@1:0-1:18 mid: :foo body: (SCOPE@1:0-1:18 tbl: [] args: (ARGS@1:8-1:12 pre_num: 0 pre_init: nil opt: nil first_post: nil post_num: 0 post_init: nil rest: nil kw: nil kwrest: nil block: nil) body: nil)))
$ ./ruby -e 'pp RubyVM::AbstractSyntaxTree.parse("def foo(); end")' 
(SCOPE@1:0-1:14
 tbl: []
 args: nil
 body: (DEFN@1:0-1:14 mid: :foo body: (SCOPE@1:0-1:14 tbl: [] args: (ARGS@1:8-1:8 pre_num: 0 pre_init: nil opt: nil first_post: nil post_num: 0 post_init: nil rest: nil kw: nil kwrest: nil block: nil) body: nil)))
$

The bodies are exactly the same here.

Updated by ufuk (Ufuk Kayserilioglu) about 6 hours ago Actions #1 [ruby-core:125204]

I am guessing that the &nil case should read block: false by comparing it to the **nil case:

❯ ruby -e 'pp RubyVM::AbstractSyntaxTree.parse("def foo(**nil); end")'
(SCOPE@1:0-1:19
 tbl: []
 args: nil
 body:
   (DEFN@1:0-1:19
    mid: :foo
    body:
      (SCOPE@1:0-1:19
       tbl: []
       args:
         (ARGS@1:8-1:13
          pre_num: 0
          pre_init: nil
          opt: nil
          first_post: nil
          post_num: 0
          post_init: nil
          rest: nil
          kw: false
          kwrest: false
          block: nil)
       body: nil)))
Actions

Also available in: PDF Atom