Skip to content

Commit

Permalink
Remove skip_space at end of Call
Browse files Browse the repository at this point in the history
This `skip_space` would consume trailing comments, newlines and comments
after newlines which on calls without parentheses.
It would be fine to keep it when there are parentheses (because then we
expect `OP_RPAREN`), but it seems to be entirely unnecessary.
  • Loading branch information
straight-shoota committed Mar 8, 2024
1 parent b79ea16 commit 11c2d2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,14 @@ describe Crystal::Formatter do
end
end

# #14256
assert_format <<-CRYSTAL
foo bar # comment
# doc
def baz; end
CRYSTAL

# CVE-2021-42574
describe "Unicode bi-directional control characters" do
['\u202A', '\u202B', '\u202C', '\u202D', '\u202E', '\u2066', '\u2067', '\u2068', '\u2069'].each do |char|
Expand Down
2 changes: 0 additions & 2 deletions src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2981,8 +2981,6 @@ module Crystal
end

def finish_args(has_parentheses, has_newlines, ends_with_newline, found_comment, column)
skip_space

if has_parentheses
if @token.type.op_comma?
next_token
Expand Down

0 comments on commit 11c2d2f

Please sign in to comment.