Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflow from function definition #31861

Closed
dlfivefifty opened this issue Apr 28, 2019 · 4 comments
Closed

StackOverflow from function definition #31861

dlfivefifty opened this issue Apr 28, 2019 · 4 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@dlfivefifty
Copy link
Contributor

This is also present in Julia v1.1:

julia> struct ProductSpace{T<:Tuple}
       end

julia> using StaticArrays
[ Info: Precompiling StaticArrays [90137ffa-7385-5640-81b9-e52037218182]

julia> function convert_space(::Type{ProductSpace{Tuple{SVector{M,T},T}}}, x::SVector{N,T}) where {N,M,T}
       end
convert_space (generic function with 1 method)

julia> function convert_space(::Type{ProductSpace{Tuple{T,SVector{M,T}}}}, x::SVector{N,T}) where {N,M,T}
       end
ERROR: StackOverflowError:
Stacktrace:
 [1] top-level scope at REPL[4]:1

julia> versioninfo()
Julia Version 1.3.0-DEV.121
Commit dc6c7c7e6f (2019-04-27 03:49 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.5.0)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
@dlfivefifty
Copy link
Contributor Author

Very similar to closed issue #31082

@daanhb
Copy link
Contributor

daanhb commented Jul 17, 2019

Also similar I think to issue #26487 (which arose from similar code in the same package).

@OlivierHnt
Copy link
Contributor

Follow-up of a question on Discourse. Perhaps this issue is related to the following StackOverflowError:

julia> f(x::T, y::T, z::S) where {S,T<:Vector{S}} = "method 1"
f (generic function with 1 method)

julia> f(x::T, z::S, y::T) where {S,T<:Vector{S}} = "method 2"
ERROR: StackOverflowError:
Stacktrace:
 [1] top-level scope at REPL[2]:1

julia> methods(f)
# 2 methods for generic function "f":
[1] f(x::T, y::T, z::S) where {S, T<:Array{S,1}} in Main at REPL[1]:1
[2] f(x::T, z::S, y::T) where {S, T<:Array{S,1}} in Main at REPL[2]:1

julia> f([1,2],1,[1,2])
"method 2"

julia> f([1,2],[1,2],1)
"method 1"

@martinholters
Copy link
Member

Duplicate of #26487

Replacing ProductSpace with Val and SVector{_,T} with Val{T} leads to the same reduction as in #26487, so closing as dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants