Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines before comments #1025

Open
kddnewton opened this issue Jun 12, 2024 · 0 comments
Open

Newlines before comments #1025

kddnewton opened this issue Jun 12, 2024 · 0 comments

Comments

@kddnewton
Copy link

In the following code:

class C
  # foo
end

I would expect the newline token after the C constant to be emitted before the comment token, but it is the opposite:

irb(main):005> Parser::CurrentRuby.new.tokenize(Parser::Source::Buffer.new("", source: "class C\n# foo\nend\n"))
=> 
[s(:class,
  s(:const, nil, :C), nil, nil),
 [#<Parser::Source::Comment :2:1 "# foo">],
 [[:kCLASS, ["class", #<Parser::Source::Range  0...5>]],
  [:tCONSTANT, ["C", #<Parser::Source::Range  6...7>]],
  [:tCOMMENT, ["# foo", #<Parser::Source::Range  8...13>]],
  [:tNL, [nil, #<Parser::Source::Range  7...8>]],
  [:kEND, ["end", #<Parser::Source::Range  14...17>]],
  [:tNL, [nil, #<Parser::Source::Range  17...18>]]]]

I can work around this, but I just want to clarify what the rule is here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant