tecosaur / About.jl

Mirror of https://code.tecosaur.net/tec/About.jl
Mozilla Public License 2.0
133 stars 7 forks source link

`about(BigInt(0))` throws exception #26

Closed screwdog closed 4 weeks ago

screwdog commented 2 months ago

On Julia 1.10 an exception occurs when using About on BigInt values.

julia> about(BigInt(1))
BigInt (mutable) (<: Signed <: Integer <: Real <: Number <: Any), occupies 16B directly (referencing 24B in total)
 alloc::Int32       4B 000000 … 00001 1
  size::Int32       4B 000000 … 00001 1
ERROR: MethodError: no method matching face!(::String, ::Symbol)

Closest candidates are:
  face!(::Union{StyledStrings.AnnotatedStrings.AnnotatedString, SubString{<:StyledStrings.AnnotatedStrings.AnnotatedString}}, ::Union{Symbol, StyledStrings.Face, Vector{<:Union{Symbol, StyledStrings.Face}}})
   @ StyledStrings ~/.julia/packages/StyledStrings/rd5VN/src/faces.jl:622

Stacktrace:
 [1] memorylayout(io::Base.TTY, value::BigInt)
   @ About ~/.julia/packages/About/52iMk/src/values.jl:106
 [2] about(io::Base.TTY, value::BigInt)
   @ About ~/.julia/packages/About/52iMk/src/values.jl:43
[...]

Version info:

Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13900KF
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, goldmont)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_EDITOR = code
matthias314 commented 2 months ago

I've come across the same issue with my package LinearCombinations.jl:

julia> using About, LinearCombinations

julia> a = Linear('a'+k => k for k in 1:20)
13*n+19*t+5*f+20*u+2*c+3*d+4*e+15*p+14*o+12*m+6*g+7*h+8*i+9*j+10*k+11*l+17*r+16*q+b+18*s

julia> about(a)
Linear{Char, Int64} (<: AbstractLinear{Char, Int64} <: Any), occupies 8B directly (referencing 992B in total)
ERROR: MethodError: no method matching face!(::String, ::Symbol)

Closest candidates are:
  face!(::Union{StyledStrings.AnnotatedStrings.AnnotatedString, SubString{<:StyledStrings.AnnotatedStrings.AnnotatedString}}, ::Union{Symbol, StyledStrings.Face, Vector{<:Union{Symbol, StyledStrings.Face}}})
   @ StyledStrings ~/.julia/packages/StyledStrings/rd5VN/src/faces.jl:622

Stacktrace:
 [1] memorylayout(io::Base.TTY, value::Linear{Char, Int64})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:106
 [2] about(io::Base.TTY, value::Linear{Char, Int64})
   @ About ~/.julia/packages/About/52iMk/src/values.jl:43
 [3] about(x::Linear{Char, Int64})
   @ About ~/.julia/packages/About/52iMk/src/About.jl:201
 [4] top-level scope
   @ REPL[9]:1
christiangnrd commented 1 month ago

I wasn't able to reproduce the BigInt failure, but for the LinearCombinations reproducer, I believe implementing the relevant fixes from https://github.com/JuliaLang/julia/pull/54948/files in the StyledStrings.jl compat branch would fix the issue.

tecosaur commented 4 weeks ago

Trying BigInt(1), it seems fine on the development version, and StyledStrings compat work is incoming, so I'll close this for now but do let me know if this remains unfixed :slightly_smiling_face:

julia> about(BigInt(1))
BigInt (mutable) (<: Signed <: Integer <: Real <: Number <: Any), occupies 16B directly (referencing 24B in total)
 alloc::Int32       4B 00000000000000000000000000000001                                 1
  size::Int32       4B 00000000000000000000000000000001                                 1
     d::Ptr{UInt64} 8B 0000000000000000000000000000000000100011011011001100001111010000 Ptr{UInt64} @0x00000000236cc3d0

 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
        4B               4B                        8B