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

Core.Compiler.return_type is inserting an Array UnionAll out of nowhere #35910

Open
schlichtanders opened this issue May 16, 2020 · 0 comments
Open

Comments

@schlichtanders
Copy link

schlichtanders commented May 16, 2020

Hi Julia core team,

today I stumbled upon some magic breaking down.
Core.Compiler.return_type should be taken cautiously, I know, however it worked super well in many many cases for me. But this one.

struct One{T}
  value::T
end
struct Two{T}
  value::T
end
Base.map(f, x::One) = One(f(x.value))
Base.map(f, x::Two) = Two(f(x.value))

Core.Compiler.return_type(map, Tuple{typeof(string), Union{One{Int}, Two{T}} where T})

the expected outcome is

Union{One{String}, Two{_A} where _A}

however it returns

Union{One{String}, Array{T,N} where T where N, Two{_A} where _A}

as you see, somehow an Array UnionAll got inserted.

For sure, this has something todo with the quite special UnionAll construction Union{One{Int}, Two{T}} where T} where the UnionAll variable is only used for part of the inner Union.


EDIT

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant