Skip to content

Commit

Permalink
- lexer.rl: allow spaces before comments-before-leading-dot. (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich committed Mar 2, 2020
1 parent 323b6ab commit 41ec100
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser/lexer.rl
Expand Up @@ -2473,7 +2473,7 @@ class Parser::Lexer

# Here we use '\n' instead of w_newline to not modify @newline_s
# and eventually properly emit tNL
(w_space_comment '\n')+
(c_space* w_space_comment '\n')+
=> {
if @version < 27
# Ruby before 2.7 doesn't support comments before leading dot.
Expand Down
14 changes: 14 additions & 0 deletions test/test_parser.rb
Expand Up @@ -7644,12 +7644,26 @@ def test_comments_before_leading_dot__27
%q{},
SINCE_2_7)

assert_parses(
s(:send,
s(:send, nil, :a), :foo),
%Q{a #\n #\n.foo\n},
%q{},
SINCE_2_7)

assert_parses(
s(:csend,
s(:send, nil, :a), :foo),
%Q{a #\n#\n&.foo\n},
%q{},
SINCE_2_7)

assert_parses(
s(:csend,
s(:send, nil, :a), :foo),
%Q{a #\n #\n&.foo\n},
%q{},
SINCE_2_7)
end

def test_comments_before_leading_dot__before_27
Expand Down

0 comments on commit 41ec100

Please sign in to comment.