You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
insert promote_rule(::Type{T}, ::Type{Tf}) where {T<:Normed, Tf<:AbstractFloat} in FixedPointNumbers at /home/tim/.julia/packages/FixedPointNumbers/w2pxG/src/normed.jl:310 invalidated:
@@ -396,14 +398,14 @@ One does not have to look at this list for very long to see that the majority of
396
398
Consider the line `backedges: MethodInstance for (::Type{T} where T<:AbstractChar)(::Int32) triggered...`.
397
399
We can see which method this is by the following:
398
400
399
-
```
401
+
```julia-repl
400
402
julia> which(Char, (Int32,))
401
403
(::Type{T})(x::Number) where T<:AbstractChar in Base at char.jl:48
402
404
```
403
405
404
406
or directly as
405
407
406
-
```
408
+
```julia-repl
407
409
julia> tree = trees[end]
408
410
insert (::Type{X})(x::Real) where X<:FixedPoint in FixedPointNumbers at /home/tim/.julia/packages/FixedPointNumbers/w2pxG/src/FixedPointNumbers.jl:51 invalidated:
409
411
mt_backedges: signature Tuple{Type{T} where T<:Int64,Int64} triggered MethodInstance for convert(::Type{T}, ::Int64) where T<:Int64 (1 children) ambiguous
@@ -426,7 +428,7 @@ We'll see how to work with `InstanceTree`s in a moment, for now we want to focus
426
428
You may find it surprising that this method signature is ambiguous with `(::Type{X})(x::Real) where X<:FixedPoint`: after all, an `AbstractChar` is quite different from a `FixedPoint` number.
427
429
We can discover why with
428
430
429
-
```
431
+
```julia-repl
430
432
julia> tree.method.sig
431
433
Tuple{Type{X},Real} where X<:FixedPoint
432
434
@@ -441,7 +443,7 @@ These two signatures have non-empty intersection.
441
443
The second parameter, `Int32`, makes sense as the intersection of `Int32` and `Real`.
@@ -454,7 +456,7 @@ Consequently, we can turn our attention to other cases.
454
456
455
457
Let's look at the next item up the list:
456
458
457
-
```
459
+
```julia-repl
458
460
julia> tree = trees[end-1]
459
461
insert reduce_empty(::typeof(Base.mul_prod), ::Type{F}) where F<:FixedPoint in FixedPointNumbers at /home/tim/.julia/packages/FixedPointNumbers/w2pxG/src/FixedPointNumbers.jl:225 invalidated:
460
462
backedges: MethodInstance for reduce_empty(::Function, ::Type{T} where T) triggered MethodInstance for reduce_empty(::Base.BottomRF{typeof(max)}, ::Type{VersionNumber}) (136 children) more specific
@@ -475,7 +477,7 @@ It is not clear why such methods should be invalidating, and this may be a Julia
475
477
476
478
If you try
477
479
478
-
```
480
+
```julia-repl
479
481
julia> trees = invalidation_trees(@snoopr using StaticArrays)
480
482
```
481
483
@@ -493,7 +495,7 @@ use the default method.
493
495
The vast majority of the rest appear to derive from ambiguities.
494
496
However, one more interesting case we've not seen before is
495
497
496
-
```
498
+
```julia-repl
497
499
julia> tree = trees[end-7]
498
500
insert unsafe_convert(::Type{Ptr{T}}, m::Base.RefValue{FA}) where {N, T, D, FA<:FieldArray{N,T,D}} in StaticArrays at /home/tim/.julia/packages/StaticArrays/mlIi1/src/FieldArray.jl:124 invalidated:
499
501
mt_backedges: signature Tuple{typeof(Base.unsafe_convert),Type{Ptr{_A}} where _A,Base.RefValue{_A} where _A} triggered MethodInstance for unsafe_convert(::Type{Ptr{Nothing}}, ::Base.RefValue{_A} where _A) (159 children) more specific
@@ -504,7 +506,7 @@ has been only partially specified: it depends on a type parameter `_A`.
504
506
Where does such a signature come from?
505
507
You can extract this line with
506
508
507
-
```
509
+
```julia-repl
508
510
julia> trigger = tree[:mt_backedges, 1]
509
511
MethodInstance for unsafe_convert(::Type{Ptr{Nothing}}, ::Base.RefValue{_A} where _A) at depth 0 with 159 children
510
512
@@ -608,7 +610,7 @@ Replacing `keys(dct)` with `Base.KeySet(dct)` (which is the default consequence
608
610
Let's return to our FixedPointNumbers `reduce_empty` example above.
609
611
A little prodding as done above reveals that this corresponds to the definition
610
612
611
-
```
613
+
```julia-repl
612
614
julia> mi, invtree = tree[:backedges, 1]
613
615
MethodInstance for reduce_empty(::Function, ::Type{T} where T) => MethodInstance for reduce_empty(::Base.BottomRF{typeof(max)}, ::Type{VersionNumber}) at depth 0 with 136 children
so that we get the same result but don't rely on the fallback.
653
655
But perhaps a better approach is to see who's calling it:
654
656
655
-
```
657
+
```julia-repl
656
658
julia> invtree.mi
657
659
MethodInstance for reduce_empty(::Base.BottomRF{typeof(max)}, ::Type{VersionNumber})
658
660
@@ -671,14 +673,14 @@ julia> invtree.children
671
673
This illustrates how to work with an `InstanceTree`: you access the MethodInstance through `.mi` and its callers through `.children`.
672
674
Let's start with the first one:
673
675
674
-
```
676
+
```julia-repl
675
677
julia> node = invtree.children[1]
676
678
MethodInstance for reduce_empty_iter(::Base.BottomRF{typeof(max)}, ::Set{VersionNumber}, ::Base.HasEltype) at depth 1 with 38 children
677
679
```
678
680
679
681
We can display the whole tree using `show(node)`:
680
682
681
-
```
683
+
```julia-repl
682
684
julia> show(node)
683
685
MethodInstance for reduce_empty_iter(::Base.BottomRF{typeof(max)}, ::Set{VersionNumber}, ::Base.HasEltype)
684
686
MethodInstance for reduce_empty_iter(::Base.BottomRF{typeof(max)}, ::Set{VersionNumber})
@@ -733,7 +735,7 @@ Adding this to `Pkg` would be type-piracy, since `max`, `BottomRF`, and `Version
733
735
But there are other possible fixes.
734
736
A little higher up the tree we see a call to `mapreduce`, and this presents another opportunity because `mapreduce` allows you to supply an `init` value:
0 commit comments