From cf0c2856eebc047fc5bae014a7d8ee6b94062b26 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 26 Jun 2026 17:05:06 +0100 Subject: [PATCH] Update is_binaryop_nestable to be compatible with JuliaSyntax@1 --- HISTORY_v2.md | 4 ++++ Project.toml | 2 +- src/styles/blue/pretty.jl | 4 +++- test/issues.jl | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/HISTORY_v2.md b/HISTORY_v2.md index 04f88eb11..a3fb5c329 100644 --- a/HISTORY_v2.md +++ b/HISTORY_v2.md @@ -1,3 +1,7 @@ +# v2.10.1 + +Fixed a formatting regression for BlueStyle introduced in 2.5.0. (#1013, #1193) + # v2.10.0 Added a new formatting option, `max_iterations`, which controls the number of rounds of formatting that JuliaFormatter will apply. diff --git a/Project.toml b/Project.toml index 25f11dd80..e8b4b688f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "JuliaFormatter" uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899" -version = "2.10.0" +version = "2.10.1" authors = ["Dominique Luna and contributors"] [workspace] diff --git a/src/styles/blue/pretty.jl b/src/styles/blue/pretty.jl index d807d0e26..18b44ec81 100644 --- a/src/styles/blue/pretty.jl +++ b/src/styles/blue/pretty.jl @@ -38,7 +38,9 @@ function is_binaryop_nestable(::BlueStyle, cst::JuliaSyntax.GreenNode) # don't, there are idempotence issues because on the second pass this will return true. # This is a massive pain to do though. # See https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/1175 - if is_assignment(cst) && haschildren(cst) && is_iterable(cst[end]) + if (is_assignment(cst) || defines_function(cst)) && + haschildren(cst) && + is_iterable(cst[end]) return false end return is_binaryop_nestable(DefaultStyle(), cst) diff --git a/test/issues.jl b/test/issues.jl index 9b9877c3d..6fc9b513e 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -2520,6 +2520,15 @@ end end end + @testset "1013" begin + s = "check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints(ex, options, options.maxsize)" + out = """ + check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints( + ex, options, options.maxsize + )""" + test_format(s, out, BlueStyle()) + end + @testset "1025" begin # from julia@1.12.6 Compiler/src/typelimits.jl s = """