Skip to content

Commit

Permalink
fix #779 (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna authored Dec 10, 2023
1 parent 4152c35 commit 4bb1984
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
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

2 comments on commit 4bb1984

@domluna
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96855

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.44 -m "<description of version>" 4bb1984cf8352e69b387f5f3563331b4461010b2
git push origin v1.0.44

Please sign in to comment.