Skip to content

StackOverflow error using tuple types as type parameter #22239

@daanhb

Description

@daanhb

The following code produces a StackOverflowError on 0.6 RC2:

bar(::Type{Val{Tuple{T,T}}}) where {T} = 1
bar(::Type{Val{Tuple{Int,T}}}) where {T} = 2

Output when running julia foo.jl with the above two lines as contents:

ERROR: LoadError: StackOverflowError:
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:569
 [2] include(::String) at ./sysimg.jl:14
 [3] process_options(::Base.JLOptions) at ./client.jl:305
 [4] _start() at ./client.jl:371
while loading /tmp/foo.jl, in expression starting on line 2

Yet, everything works fine if the order of the two lines is reversed!

  • The problem goes away if you remove the extra complexity of the Val above, i.e. the tuple types have to be type parameters. Maybe that is not a valid thing to do? The above is a MWE, the context was code to convert between nested tuples and flat tuples.
  • The second line matches the first if T=Int, but that is not essential. You can replace the Int with Tuple{T,T} so it never matches the first line, and the problem remains.

Version info:

julia> versioninfo()
Julia Version 0.6.0-rc2.0
Commit 68e911b (2017-05-18 02:31 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviortypes and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions