Skip to content

Conversation

@thevolatilebit
Copy link
Contributor

@thevolatilebit thevolatilebit commented Sep 7, 2022

Since JuliaLang/julia#39448, getproperty has been deprecated in favor of getfield.

Since Julia's #39448, `getproperty` has been deprecated in favor of `getfield`.
@ChrisRackauckas
Copy link
Member

That PR is only about Pairs, I don't see how it applies here?

@thevolatilebit
Copy link
Contributor Author

thevolatilebit commented Sep 7, 2022

I get

┌ Warning: use values(kwargs) and keys(kwargs) instead of kwargs.data and kwargs.itr
│   caller = DualEltypeChecker at forwarddiff.jl:62 [inlined]
└ @ Core ~/.julia/packages/DiffEqBase/iK5G7/src/forwarddiff.jl:62

Maybe T in

struct DualEltypeChecker{T}
    x::T
    counter::Int
    DualEltypeChecker(x::T, counter::Int) where {T} = new{T}(x, counter + 1)
end
function (dec::DualEltypeChecker)(::Val{Y}) where {Y}
    isdefined(dec.x, Y) || return Any
    anyeltypedual(getproperty(dec.x, Y), dec.counter)
end

is of type Pairs?

The proposed change seems to fix this.

@ChrisRackauckas
Copy link
Member

The solution would then be to create a separate dispatch on function (dec::DualEltypeChecker{<:Pairs})(::Val{Y}) where {Y} which uses getfield (and put a comment about that PR above it. Most of the time, you want to use getproperty: getfield is usually the incorrect thing to do. But it sounds like on Pairs you do want to use getfield.

@thevolatilebit
Copy link
Contributor Author

Thanks, updated the PR.

@ChrisRackauckas
Copy link
Member

Can you add a test with @test_nowarn?

@ChrisRackauckas
Copy link
Member

Test failure looks real

@thevolatilebit
Copy link
Contributor Author

Thanks, sure, the issue is that Pairs seems to be available only in v1.7+. Will update that.

@ChrisRackauckas
Copy link
Member

Beautiful. Don't worry about the formatter, I'll merge and run it. Thanks!

@ChrisRackauckas ChrisRackauckas merged commit 12a4462 into SciML:master Sep 8, 2022
@thevolatilebit
Copy link
Contributor Author

Beautiful. Don't worry about the formatter, I'll merge and run it. Thanks!

Great, many thanks!

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.

2 participants