Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeVar Bug #299

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Mooncake"
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.4.16"
version = "0.4.17"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
7 changes: 7 additions & 0 deletions src/fwds_rvs_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@

can_produce_zero_rdata_from_type(::Type{<:IEEEFloat}) = true

can_produce_zero_rdata_from_type(::Type{<:Type}) = true

can_produce_zero_rdata_from_type(::Type{Union{}}) = true

"""
CannotProduceZeroRDataFromType()

Expand Down Expand Up @@ -647,6 +651,9 @@

zero_rdata_from_type(::Type{P}) where {P<:IEEEFloat} = zero(P)

zero_rdata_from_type(::Type{<:Type}) = NoRData()

zero_rdata_from_type(::Type{Union{}}) = NoRData()

Check warning on line 656 in src/fwds_rvs_data.jl

View check run for this annotation

Codecov / codecov/patch

src/fwds_rvs_data.jl#L656

Added line #L656 was not covered by tests

"""
InvalidRDataException(msg::String)
Expand Down
10 changes: 10 additions & 0 deletions test/fwds_rvs_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ end
@test !Mooncake.can_produce_zero_rdata_from_type(Tuple)
@test !Mooncake.can_produce_zero_rdata_from_type(Union{Tuple{Float64}, Tuple{Int}})
@test !Mooncake.can_produce_zero_rdata_from_type(Tuple{T, T} where {T<:Integer})
@test Mooncake.can_produce_zero_rdata_from_type(Type{Float64})

# Edge case: Types with unbound type parameters.
P = (Type{T} where {T}).body
@test Mooncake.can_produce_zero_rdata_from_type(P)
@test Mooncake.zero_rdata_from_type(P) === NoRData()

# Check for ambiguity.
@test Mooncake.can_produce_zero_rdata_from_type(Union{})
@test Mooncake.zero_rdata_from_type(Union{}) === NoRData()
end
@testset "lazy construction checks" begin
# Check that lazy construction is in fact lazy for some cases where performance
Expand Down
Loading