Poor inference for `pvalue`
The inferred return type of pvalue is quite imprecise or even weird for some tests. This appears to be a regression from some time ago (as it didn't happen on an old state I had), but the problem doesn't go away when using old versions so I suspect it's related to a change in a dependency.
julia> @code_warntype pvalue(SignedRankTest([1], [1]))
MethodInstance for HypothesisTests.pvalue(::ExactSignedRankTest{Int64})
from pvalue(x::ExactSignedRankTest; tail) in HypothesisTests at /home/milan/.julia/dev/HypothesisTests/src/wilcoxon.jl:135
Arguments
#self#::Core.Const(HypothesisTests.pvalue)
x::ExactSignedRankTest{Int64}
Body::Union{Nothing, Float64, Int64}
1 ─ %1 = HypothesisTests.:(var"#pvalue#33")(:both, #self#, x)::Union{Nothing, Float64, Int64}
└── return %1
julia> @code_warntype pvalue(EqualVarianceTTest([1], [1]))
MethodInstance for HypothesisTests.pvalue(::EqualVarianceTTest)
from pvalue(x::HypothesisTests.TTest; tail) in HypothesisTests at /home/milan/.julia/dev/HypothesisTests/src/t.jl:31
Arguments
#self#::Core.Const(HypothesisTests.pvalue)
x::EqualVarianceTTest
Body::Any
1 ─ %1 = HypothesisTests.:(var"#pvalue#29")(:both, #self#, x)::Any
└── return %1
# But
julia> @code_warntype pvalue(MannWhitneyUTest([1], [1]))
MethodInstance for HypothesisTests.pvalue(::ExactMannWhitneyUTest{Float64})
from pvalue(x::ExactMannWhitneyUTest; tail) in HypothesisTests at /home/milan/.julia/dev/HypothesisTests/src/mann_whitney.jl:136
Arguments
#self#::Core.Const(HypothesisTests.pvalue)
x::ExactMannWhitneyUTest{Float64}
Body::Float64
1 ─ %1 = HypothesisTests.:(var"#pvalue#27")(:both, #self#, x)::Float64
└── return %1
This is one of the causes of https://github.com/JuliaStats/StatsBase.jl/issues/771, though the error is due to a bug in StatsBase.
They are all caused by HypothesisTests. The first one due to some simple type stability issues (checked locally that fixing them fixes the example) and the second one since the struct EqualVarianceTTest contains fields of abstract types (I assume, did not try to fix it).
OK, cool. That's funny because originally I didn't get the same inference issues, they only appeared after I updated to the latest version of all packages. But I'm unable to go back to the original state now as I didn't save the versions.
Ah, and any idea where the Nothing part for ExactSignedRankTest comes from? :-/
Yes. There was no else branch. I fixed it in the PR, it was the main reason for the check_tail function and replacing the last elseif with else.