Project

General

Profile

Actions

Bug #21983

closed

RubyVM::AST no way to find &nil

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

Added by kddnewton (Kevin Newton) 8 days ago. Updated 8 days ago.

Status:
Closed
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) 8 days 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)))

Updated by nobu (Nobuyoshi Nakada) 8 days ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|13926009ba829f42037719b9a163a41a8d67abed.


[Bug #21983] Make &nil distinguishable from nonexistent block arg

Updated by nobu (Nobuyoshi Nakada) 8 days ago Actions #3

  • Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONTNEED
Actions

Also available in: PDF Atom