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

fix #779 #790

Merged
merged 1 commit into from
Dec 10, 2023
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
authors = ["Dominique Luna <dluna132@gmail.com>"]
version = "1.0.43"
version = "1.0.44"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
Expand Down
18 changes: 10 additions & 8 deletions src/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,7 @@ end
"""
binaryop_to_whereop(fst::FST, s::State)

Handles the case of a function def defined
as:
Handles the case of a function def defined as:

```julia
foo(a::A)::R where A = body
Expand Down Expand Up @@ -435,13 +434,16 @@ function binaryop_to_whereop!(fst::FST, s::State)
# transform fst[1] to a Where
oldbinop = fst[1]
oldwhereop = fst[1][end]
binop = FST(Binary, fst[1].indent)

# foo(a::A)
add_node!(binop, oldbinop[1], s)
# foo(a::A)::
add_node!(binop, oldbinop[2], s, join_lines = true)
# foo(a::A)::R
# get everything up to the where
binop = FST(Binary, fst[1].indent)
for n in oldbinop.nodes
if n.typ === Where
break
end
add_node!(binop, n, s, join_lines = true)
end
# # foo(a::A)::R gets the "R"
add_node!(binop, oldwhereop[1], s, join_lines = true)

whereop = FST(Where, fst[1].indent)
Expand Down
5 changes: 5 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1770,4 +1770,9 @@
"""
@test format_text(s, SciMLStyle()) == s
end

@testset "779" begin
s = "Int <: B where {B} && Int <: C where {C}"
fmt(s) == s
end
end
Loading