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

defining functions kills the julia interpreter #36804

Closed
schlichtanders opened this issue Jul 26, 2020 · 6 comments · Fixed by #38810
Closed

defining functions kills the julia interpreter #36804

schlichtanders opened this issue Jul 26, 2020 · 6 comments · Fixed by #38810
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior

Comments

@schlichtanders
Copy link

Hi,
I just stumbled upon a pecularity when defining certain functions. I am not sure, whether this is expected, but it looks quite frightening from a user perspective.

The following code will kill my julia repl (actually sometimes it resulted in a StackOverflow instead, however now it is always killing it immediately)
Copy paste

const Either{L, R} = Union{Some{L}, Ref{R}}
f(::Type{Either{L2, R}}, ::Type{Either{L1, R}}) where {L1, R, L2 <: L1} = Either{L1, R}
f(::Type{Either{L, R1}}, ::Type{Either{L, R2}}) where {L, R1, R2 <: R1} = Either{L, R1}

and boom.

my versions:

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)
Environment:
  JULIA_NUM_THREADS = 8
@fredrikekre
Copy link
Member

Probably it breaks some internal functions similar to #35436 and linked issues?

@thofma
Copy link
Contributor

thofma commented Jul 26, 2020

He is not overloading a Base function though. All the linked issues overloaded Base functions.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 26, 2020

Yeah, this is a type system bug

@vtjnash vtjnash added the domain:types and dispatch Types, subtyping and method dispatch label Jul 26, 2020
@Keno Keno added the kind:bug Indicates an unexpected problem or unintended behavior label Jul 26, 2020
@JeffBezanson
Copy link
Sponsor Member

Looks similar to #36185 and #36544, possibly same issue.

@zlatanvasovic
Copy link
Contributor

I believe re-ordering the 2nd and 3rd declarations solves your issue:

const Either{L, R} = Union{Some{L}, Ref{R}}
f(::Type{Either{L, R1}}, ::Type{Either{L, R2}}) where {L, R1, R2 <: R1} = Either{L, R1}
f(::Type{Either{L2, R}}, ::Type{Either{L1, R}}) where {L1, R, L2 <: L1} = Either{L1, R}

But I have no clue why does it solve your issue, though.

@KristofferC
Copy link
Sponsor Member

#38423 might be a dup of this.

JeffBezanson added a commit that referenced this issue Dec 10, 2020
JeffBezanson added a commit that referenced this issue Dec 10, 2020
KristofferC pushed a commit that referenced this issue Dec 17, 2020
staticfloat pushed a commit that referenced this issue Jan 15, 2021
staticfloat pushed a commit that referenced this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants