ForwardDiff2.jl icon indicating copy to clipboard operation
ForwardDiff2.jl copied to clipboard

Fail if a GlobalRef is being assigned to a Dual number.

Open YingboMa opened this issue 5 years ago • 3 comments

YingboMa avatar Jan 23 '20 04:01 YingboMa

Codecov Report

Merging #39 into master will increase coverage by 0.49%. The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #39      +/-   ##
==========================================
+ Coverage   73.26%   73.75%   +0.49%     
==========================================
  Files           7        7              
  Lines         273      282       +9     
==========================================
+ Hits          200      208       +8     
- Misses         73       74       +1
Impacted Files Coverage Δ
src/custom_dispatch.jl 94.28% <80%> (-5.72%) :arrow_down:
src/dual_context.jl 90.56% <0%> (+1.88%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5b0f8d4...e4925ff. Read the comment docs.

codecov-io avatar Jan 23 '20 05:01 codecov-io

Note that this won't solve all leaks, e.g. if you have global ref = Real[0] and put a number in there while differentiating you'll get the same issue.

I could probably also get around this by, for example, doing global foo = [x::Dual] or global foo = SomeStruct(x::Dual) (and same for setfield issues).

MikeInnes avatar Jan 23 '20 17:01 MikeInnes

I could probably also get around this by, for example, doing global foo = [x::Dual] or global foo = SomeStruct(x::Dual) (and same for setfield issues).

If the user wants to get a Dual, then it is the intended behavior.

YingboMa avatar Jan 23 '20 18:01 YingboMa