Skip to content

StackOverflow in typeintersect when using Tuple type parameters #26487

@daanhb

Description

@daanhb

I'm making a new issue for an older issue (#22239) that was partially fixed. The problem is a StackOverflow error in the following minimal working example:

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

The output using the current nightly build is:

ERROR: LoadError: StackOverflowError:
Stacktrace:
 [1] top-level scope
 [2] include at ./boot.jl:306 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1072
 [4] include(::Module, ::String) at ./sysimg.jl:29
 [5] exec_options(::Base.JLOptions) at ./client.jl:327
 [6] _start() at ./client.jl:455
in expression starting at /tmp/mwe.jl:2

As @martinholters pointed out in #22239, the error results from typeintersect as follows:

julia> typeintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T)
ERROR: StackOverflowError:
Stacktrace:
 [1] typeintersect(::Any, ::Any) at ./reflection.jl:469
 [2] top-level scope

Above examples were tested today on master:

julia> versioninfo()
Julia Version 0.7.0-DEV.4594
Commit 29a1719f95 (2018-03-15 22:41 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
Environment:

The examples do also lead to similar errors on 0.6.2.

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