Skip to content

Commit

Permalink
[Writer] Unquote keyword as method name
Browse files Browse the repository at this point in the history
Except `self` and `self?` because they need quote.
  • Loading branch information
pocke committed Dec 20, 2020
1 parent a1e6261 commit 2b03212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rbs/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def method_name(name)
s = name.to_s

if [:tOPERATOR, :kAMP, :kHAT, :kSTAR, :kLT, :kEXCLAMATION, :kSTAR2, :kBAR].include?(Parser::PUNCTS[s]) ||
(/\A[a-zA-Z_]\w*[?!=]?\z/.match?(s) && !/\A#{Parser::KEYWORDS_RE}\z/.match?(s))
(/\A[a-zA-Z_]\w*[?!=]?\z/.match?(s) && !/\Aself\??\z/.match?(s))
s
else
"`#{s}`"
Expand Down
6 changes: 5 additions & 1 deletion test/rbs/writer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ def !: () -> void
def __id__: () -> Integer
def `def`: () -> Symbol
def def: () -> Symbol
def `self`: () -> void
def `self?`: () -> void
def timeout: () -> Integer
Expand Down

0 comments on commit 2b03212

Please sign in to comment.