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 type instability/invalidations from nextind #46489

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

ranocha
Copy link
Member

@ranocha ranocha commented Aug 26, 2022

I found this while hunting some invalidations coming from ForwardDiff.jl

inserting promote_rule(::Type{R}, ::Type{ForwardDiff.Dual{T, V, N}}) where {R<:Real, T, V, N} in ForwardDiff at ~/.julia/packages/ForwardDiff/pDtsf/src/dual.jl:425 invalidated:
   backedges: 1: superseding promote_rule(::Type, ::Type) in Base at promotion.jl:310 with MethodInstance for promote_rule(::Type{Int64}, ::Type{S} where S<:Real) (1 children)
              2: superseding promote_rule(::Type, ::Type) in Base at promotion.jl:310 with MethodInstance for promote_rule(::Type{UInt8}, ::Type) (8 children)
              3: superseding promote_rule(::Type, ::Type) in Base at promotion.jl:310 with MethodInstance for promote_rule(::Type{Int64}, ::Type) (82 children)
   18 mt_cache

The output from ascend from SnoopCompile.jl showed that the output of nextind was inferred to Any but the documentation asserts that it should be an Int:

help?> nextind
search: nextind IndexCartesian MissingException current_exceptions InterruptException InvalidStateException

  nextind(str::AbstractString, i::Integer, n::Integer=1) -> Int

Note that the same type assertion is used in the line above the one I changed.

@KristofferC KristofferC merged commit 98e1b13 into JuliaLang:master Aug 26, 2022
@ranocha ranocha deleted the patch-6 branch August 26, 2022 13:39
@giordano giordano added the backport 1.8 Change should be backported to release-1.8 label Aug 26, 2022
ranocha added a commit to ranocha/julia that referenced this pull request Aug 30, 2022
KristofferC pushed a commit that referenced this pull request Aug 30, 2022
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Sep 7, 2022
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

Successfully merging this pull request may close these issues.

3 participants