Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY_v2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.11.2

Fixed a bug where YASStyle would insert a trailing comma for a function call with zero arguments, which is invalid Julia syntax. (#1225, #1226)

# v2.11.1

Fixed a bug where formatting a do-block with no argument after the `do` would cause YASStyle to crash. (#1219, #1221)
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
version = "2.11.1"
version = "2.11.2"
authors = ["Dominique Luna <dluna132@gmail.com> and contributors"]

[workspace]
Expand Down
7 changes: 6 additions & 1 deletion src/styles/yas/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,12 @@ function p_call(
# case where the last argument is followed by a comment, the closing paren will
# be placed on the next line, and in that case we want to allow a trailing
# comma.
k === K")" && add_node!(t, TrailingComma(), s)
# If `i == first_arg_idx`, then the function call is empty. In such cases adding
# a trailing comma causes a syntax error, so don't do it
if k === K")" && i != first_arg_idx
add_node!(t, TrailingComma(), s)
end

add_node!(
t,
n,
Expand Down
21 changes: 21 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3581,6 +3581,27 @@ end
end"""
test_format(s, s, YASStyle(); margin=30)
end

@testset "1225 YAS trailing comma with zero args" begin
s_ = """
f(
# Hi
)"""
s = """
f(
# Hi
)"""
test_format(s_, s, YASStyle())

s_ = """
f(
#= Hi =#
)"""
s = """
f(
#= Hi =#)"""
test_format(s_, s, YASStyle())
end
end

end
Loading