Skip to content

Empty method definition with only a comment seems to confuse syntaxsuggest #177

@mame

Description

@mame
class C
  def foo
    # comment
  end

  def bar
    "some literal"
  end

  def baz
  end

  def qux
  end

  def quux
  end
end
end # extra end

Expected:

$ ruby error.rb 
error.rb: --> error.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
>  1  class C
> 18  end
> 19  end # extra end
error.rb:19: syntax error, unexpected `end' (SyntaxError)
end # extra end
^~~

Actual:

$ ruby error.rb 
error.rb: --> error.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
   1  class C
>  4    end
> 10    def baz
> 11    end
  18  end
error.rb:19: syntax error, unexpected `end' (SyntaxError)
end # extra end
^~~

I haven't identified the exact condition to reproduce this issue, but I am wondering that an empty method definition with only comments would confuse the heuristics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions