Running this produces 80000 lines of errors:
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0-DEV.2490 (2017-11-11 17:03 UTC)
_/ |\__'_|_|_|\__'_| | Commit da34a89917* (1 day old master)
|__/ | x86_64-pc-linux-gnu
julia> using Rotations, StaticArrays
julia> (::Type{Rotations.RotMatrix{N,T,L}})(sa::StaticArrays.StaticMatrix) where {N,T,L} =
Rotations.RotMatrix(sa)
julia> RotMatrix(-4.5)
ERROR: StackOverflowError:
Stacktrace:
[1] Rotations.RotMatrix(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at /home/mauro/.julia/v0.6/Rotations/src/core_types.jl:80
[2] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[3]:1
...
[79999] Rotations.RotMatrix(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at /home/mauro/.julia/v0.6/Rotations/src/core_types.jl:80
[80000] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[3]:1
Same on 0.6.1
Note when defining instead:
julia> (::Type{Rotations.RotMatrix{N,T,L}})(sa::StaticArrays.StaticMatrix) where {N,T,L} =
Rotations.RotMatrix{N,T,L}(sa)
julia> RotMatrix(-4.5)
ERROR: StackOverflowError:
Stacktrace:
[1] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[2]:1 (repeats 80000 times)
then the lines get folded into one. I guess the problem is the 2-fold infinite recursion.
Simpler:
julia> g(x) = h(x)
g (generic function with 1 method)
julia> h(x) = g(x)
h (generic function with 1 method)
julia> g(5)
ERROR: StackOverflowError:
Stacktrace:
....
[79998] h(::Int64) at ./REPL[4]:1
[79999] g(::Int64) at ./REPL[3]:1
[80000] h(::Int64) at ./REPL[4]:1
whereas a simple recursion throws a good error:
julia> f(x) = f(x)
f (generic function with 1 method)
julia> f(5)
ERROR: StackOverflowError:
Stacktrace:
[1] f(::Int64) at ./REPL[1]:1 (repeats 80000 times)
Random keywords to make this easier to find: Long stacktrace in stackoverflow recursion.
Most helpful comment
Random keywords to make this easier to find: Long stacktrace in stackoverflow recursion.