Skip to content

Unhandled exception in YARD::Handlers::Ruby::MethodHandler when using Ruby 3.0' endless method definitions #1376

@koic

Description

@koic

YARD 0.9.26 occurs an error when trying to parse Ruby 3.0 endless method definitions.

Steps to reproduce

% cat endless_method_definition.rb
def say = puts('hello')
% yard doc endless_method_definition.rb
[error]: Unhandled exception in YARD::Handlers::Ruby::MethodHandler:
  in `endless_method_definition.rb`:1:

        1: def say = puts('hello')

Files:           0
Modules:         0 (    0 undocumented)
Classes:         0 (    0 undocumented)
Constants:       0 (    0 undocumented)
Attributes:      0 (    0 undocumented)
Methods:         0 (    0 undocumented)
 100.00% documented

Actual Output

% yard doc --debug endless_method_definition.rb
[debug]: Parsing ["endless_method_definition.rb"] with `ruby` parser
[debug]: Parsing endless_method_definition.rb
[error]: Unhandled exception in YARD::Handlers::Ruby::MethodHandler:
  in `endless_method_definition.rb`:1:

        1: def say = puts('hello')

[error]: NoMethodError: undefined method `type' for nil:NilClass
[error]: Stack trace:
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/parser/ruby/ast_node.rb:484:in `parameters'
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/handlers/ruby/method_handler.rb:70:in `format_args'
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/handlers/ruby/method_handler.rb:10:in `block in <class:MethodHandler>'
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/handlers/processor.rb:114:in `block (2 levels) in process'
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/handlers/processor.rb:112:in `each'
        /Users/koic/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/yard-0.9.26/lib/yard/handlers/processor.rb:112:in `block in process'

[debug]: Serializing to .yardoc/objects/root.dat
[debug]: Re-generating object ...
[debug]: Generating asset js/jquery.js
[debug]: Serializing to doc/js/jquery.js
[debug]: Generating asset js/app.js
[debug]: Serializing to doc/js/app.js
[debug]: Generating asset js/full_list.js
[debug]: Serializing to doc/js/full_list.js
[debug]: Generating asset css/style.css
[debug]: Serializing to doc/css/style.css
[debug]: Generating asset css/common.css
[debug]: Serializing to doc/css/common.css
[debug]: Generating asset css/full_list.css
[debug]: Serializing to doc/css/full_list.css
[debug]: Generating asset class_list.html
[debug]: Serializing to doc/class_list.html
[debug]: Generating asset method_list.html
[debug]: Serializing to doc/method_list.html
[debug]: Generating asset file_list.html
[debug]: Serializing to doc/file_list.html
[debug]: Generating asset frames.html
[debug]: Serializing to doc/frames.html
[debug]: Serializing to doc/index.html
[debug]: Serializing to doc/_index.html
[debug]: Serializing to doc/top-level-namespace.html
Files:           0
Modules:         0 (    0 undocumented)
Classes:         0 (    0 undocumented)
Constants:       0 (    0 undocumented)
Attributes:      0 (    0 undocumented)
Methods:         0 (    0 undocumented)
 100.00% documented

Expected Output

No errors.

Environment details:

  • OS: [Enter operating system / version here]
% uname -a
Darwin atelier.local 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
  • Ruby version (ruby -v): [Enter output of ruby -v]
% ruby -v
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin19]
  • YARD version (yard -v): [Enter output of yard -v]
% yard -v
yard 0.9.26
  • Relevant software dependency/versions:
    • [Any 3rd party libs required to reproduce, omit if none]

Nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions