Kolaru / MathTeXEngine.jl

A latex math mode engine in pure Julia.
MIT License
96 stars 20 forks source link

BoundsError generate_tex_elementes of a subscript with Julia 1.9.0-beta2 and OrdinaryDiffEq.jl #97

Closed jaakkor2 closed 1 year ago

jaakkor2 commented 1 year ago

With Julia v1.9.0-beta2 started as julia +beta --startup-file=no, OrdinaryDiffEq v6.37.0, MathTexEngine v0.5.4, I see

using OrdinaryDiffEq
using MathTeXEngine
generate_tex_elements(L"$a_{00}$")

errors as

ERROR: BoundsError: attempt to access Tuple{Tuple{TeXChar, GeometryBasics.Point2{Float64}, Float64}, Tuple{TeXChar, GeometryBasics.Point2{Float64}, Float64}, Tuple{TeXChar, GeometryBasics.Point2{Float64}, Float64}} at index [4]
Stacktrace:
 [1] getindex
   @ .\tuple.jl:29 [inlined]
 [2] push!(::Vector{Any}, ::Any, ::Any, ::Any, ::Any)
   @ Base .\array.jl:1077
 [3] unravel(group::MathTeXEngine.Group{Float64}, parent_pos::GeometryBasics.Point{2, Float32}, parent_scale::Float64)
   @ MathTeXEngine C:\Users\jaakkor2\.julia\packages\MathTeXEngine\yfkMo\src\engine\layout.jl:265
 [4] unravel(group::MathTeXEngine.Group{Float64}, parent_pos::GeometryBasics.Point{2, Float32}, parent_scale::Float32)
   @ MathTeXEngine C:\Users\jaakkor2\.julia\packages\MathTeXEngine\yfkMo\src\engine\layout.jl:265
 [5] unravel
   @ C:\Users\jaakkor2\.julia\packages\MathTeXEngine\yfkMo\src\engine\layout.jl:260 [inlined]
 [6] generate_tex_elements(str::LaTeXStrings.LaTeXString, font_family::MathTeXEngine.FontFamily)
   @ MathTeXEngine C:\Users\jaakkor2\.julia\packages\MathTeXEngine\yfkMo\src\engine\layout.jl:303
 [7] generate_tex_elements(str::LaTeXStrings.LaTeXString)
   @ MathTeXEngine C:\Users\jaakkor2\.julia\packages\MathTeXEngine\yfkMo\src\engine\layout.jl:295
 [8] top-level scope
   @ REPL[3]:1

Without using OrdinaryDiffEq the example works fine. Julia v1.8.5 seemed to work fine.

jaakkor2 commented 1 year ago

Simplified

using NonlinearSolve
using MathTeXEngine
generate_tex_elements(L"$a_{00}$")
jaakkor2 commented 1 year ago

A bit more simplified

using LoopVectorization
using MathTeXEngine
generate_tex_elements(L"$a_{00}$")
Kolaru commented 1 year ago

This is a problem with LoopVectorization (or one of its dependency):

julia> a = []
Any[]

julia> push!(a, 2, 3, 4)
3-element Vector{Any}:
 2
 3
 4

julia> using LoopVectorization

julia> push!(a, 2, 3, 4)
ERROR: BoundsError: attempt to access Tuple{Int64, Int64, Int64} at index [4]
Stacktrace:
 [1] getindex
   @ .\tuple.jl:29 [inlined]
 [2] push!(::Vector{Any}, ::Any, ::Any, ::Any, ::Any)
   @ Base .\array.jl:1077
 [3] top-level scope
   @ REPL[4]:1

Keeping it open until it is solved upstream.

jaakkor2 commented 1 year ago

Fixed in Julia 1.9.0-beta3, worked around in LoopVectorization 0.12.147.