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

fix #38888, pessimistic sparam inference with concrete upper bound #38899

Merged
merged 1 commit into from
Dec 18, 2020

Conversation

JeffBezanson
Copy link
Sponsor Member

The problem here is that we infer the constructor with signature T(x::S) where S<:Int, but that's type-equal to T(x::Int), so it can be picked up from the cache later. But that specialization doesn't work when called, since it thinks it doesn't know the value of S. I think the simplest fix is to do a pass refining unknown static parameters to their upper bounds when possible (concrete, only occurs covariantly). I also tried an alternate fix where we avoid inferring T(x::S) where S<:Int by normalizing the signature in specialize_method. That also works but seems more complex. We might want to do it in addition though.

I also noticed a case where we seem to return Nothing instead of nothing (!!)

@JeffBezanson JeffBezanson added kind:bugfix This change fixes an existing bug backport 1.6 Change should be backported to release-1.6 labels Dec 15, 2020
@Keno
Copy link
Member

Keno commented Dec 15, 2020

Doesn't this just punt the problem one level down the line, as in:

struct S38888{T}
    S38888(x::S) where {S2<:Int,S<:S2} = new{S}()
end
f38888() = S38888(Base.inferencebarrier(3))
@test f38888() isa S38888

@JeffBezanson
Copy link
Sponsor Member Author

Hmm, I guess in that case the other fix I described is more comprehensive.

@KristofferC
Copy link
Sponsor Member

Ready to go?

@JeffBezanson JeffBezanson merged commit a88c435 into master Dec 18, 2020
@JeffBezanson JeffBezanson deleted the jb/fix38888 branch December 18, 2020 16:59
@KristofferC KristofferC mentioned this pull request Dec 19, 2020
26 tasks
KristofferC pushed a commit that referenced this pull request Dec 19, 2020
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label Jan 6, 2021
staticfloat pushed a commit that referenced this pull request Jan 15, 2021
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants