Skip to content

Inference error in Julia 1.8 #178

Closed
JuliaLang/julia
#44282
@fredrikekre

Description

@fredrikekre

Found in PkgEval:

using Test, Tensors

function Ψ(C)
    μ = 1e10
    Kb = 1.66e11
    detC = det(C)
    J = sqrt(detC)
    Ĉ = detC^(-1/3)*C
    return 1/2** (tr(Ĉ)- 3) + Kb*(J-1)^2)
end

const F = one(Tensor{2,2}) + rand(Tensor{2,2})
const C = tdot(F)

@inferred hessian(Ψ, C)

git bisects points to JuliaLang/julia@e3b681c (cc @aviatesk if you have time to have a look).

e3b681c6872d87d74db63dd7ec3da2beee8e3ae4 is the first bad commit
commit e3b681c6872d87d74db63dd7ec3da2beee8e3ae4
Author: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Date:   Wed Feb 2 10:39:19 2022 +0900

    inference: always use const-prop'ed result (#44001)
    
    Previously, for `invoke`/opaque closure callsite, we use constant-prop'ed
    method body only when the inferred return type gets strictly improved
    by const-prop. But since the inliner is now able to inline the method
    body from `InferenceResult`, I believe it is always better to use method
    body shaped up by const-prop' no matter if the return type is improved
    (as we already do for ordinal call sites).
    
    > use constant prop' result even when the return type doesn't get refined
    ```julia
    const Gx = Ref{Any}()
    Base.@constprop :aggressive function conditional_escape!(cnd, x)
        if cnd
            Gx[] = x
        end
        return nothing
    end
    @test fully_eliminated((String,)) do x
        Base.@invoke conditional_escape!(false::Any, x::Any)
    end
    ```

:040000 040000 c48f5010124361b197808e99d69f5cd6d8327c73 e1c3e4c63b4c7128dbb0b4acae99ba864a580983 M     base
:040000 040000 5699d8a554ff36c25a94d4e2ed9576a2c6aab040 519f5968c110b456bbdab1b57015111630741106 M     test
bisect run success

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions