julia-vscode / DocumentFormat.jl

Auto-formatter for Julia
Other
62 stars 18 forks source link

Code reformat causes weird behaviour in ternary operator #40

Closed asinghvi17 closed 5 years ago

asinghvi17 commented 5 years ago

Original:

minfinite_scalar(a::T, b::T) where {T} = isfinite(a) ? (b < a ? b : a) : b
maxfinite_scalar(a::T, b::T) where {T} = isfinite(a) ? (b > a ? b : a) : b
minfinite_scalar(a::T, b::T) where {T<:Union{Integer,FixedPoint}} = b < a ? b : a
maxfinite_scalar(a::T, b::T) where {T<:Union{Integer,FixedPoint}} = b > a ? b : a

Reformatted:

minfinite_scalar(a::T, b::T) where {T} = isfinite(a) ? (b < a ?b : a : b
maxfinite_scalar(a::T, b::T) where {T} = isfinite(a) ? (b > a ?b : a : b
minfinite_scalar(a::T, b::T) where {T <: Union{Integer,FixedPoint} = b< a ? b : a
maxfinite_scalar(a::T, b::T) where {T <: Union{Integer,FixedPoint} = b> a ? b : a

In short: missing brackets, no spaces between variable and operator.

ZacLN commented 5 years ago

What version is this? I can't replicate on master

asinghvi17 commented 5 years ago

It was on 0.4.0, can confirm it's fixed on master.