@@ -296,7 +296,7 @@ function show(io::IO, x::FixedPoint{T,f}) where {T,f}
296296 end
297297end
298298
299- if VERSION < v " 1.6.0-DEV.356"
299+ if VERSION < v " 1.6.0-DEV.356" # JuliaLang/julia#36107
300300 function Base. showarg (io:: IO , a:: Array{X} , toplevel) where {X<: FixedPoint }
301301 toplevel || print (io, " ::" )
302302 print (io, " Array{" )
@@ -340,13 +340,17 @@ scaledual(::Type{Tdual}, x::FixedPoint) where Tdual = convert(Tdual, 1/rawone(x)
340340scaledual (:: Type{Tdual} , x:: AbstractArray{T} ) where {Tdual, T <: FixedPoint } =
341341 convert (Tdual, 1 / rawone (T)), reinterpret (rawtype (T), x)
342342
343- @noinline function throw_converterror (:: Type{X} , x) where {X <: FixedPoint }
344- n = 2 ^ bitwidth (X)
345- bitstring = bitwidth (X) == 8 ? " an 8-bit" : " a $(bitwidth (X)) -bit"
343+ @noinline function throw_converterror (:: Type{X} , @nospecialize (x)) where X <: FixedPoint
344+ nbits = bitwidth (rawtype (X))
346345 io = IOBuffer ()
347- show (IOContext (io, :compact => true ), typemin (X)); Xmin = String (take! (io))
348- show (IOContext (io, :compact => true ), typemax (X)); Xmax = String (take! (io))
349- throw (ArgumentError (" $X is $bitstring type representing $n values from $Xmin to $Xmax ; cannot represent $x " ))
346+ showtype (io, X)
347+ print (io, " is " )
348+ print (io, nbits == 8 ? " an " : " a " , nbits, " -bit type representing " )
349+ print (io, nbits <= 16 ? string (2 ^ nbits) : " 2^$nbits " , " values from " )
350+ print (IOContext (io, :compact => true ), typemin (X), " to " )
351+ print (IOContext (io, :compact => true ), typemax (X), " ; " )
352+ print (io, " cannot represent " , x)
353+ throw (ArgumentError (String (take! (io))))
350354end
351355
352356rand (:: Type{T} ) where {T <: FixedPoint } = reinterpret (T, rand (rawtype (T)))
0 commit comments