Skip to content

Commit a623e8f

Browse files
committed
test: fix imaginary type instability from Interfaces.jl
This was from `tree` being treated as an iterator!
1 parent 7978292 commit a623e8f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/base.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ struct TreeMapreducer{
121121
end
122122

123123
@generated function call_mapreducer(
124-
mapreducer::TreeMapreducer{D,ID,F1,F2,G,H}, tree::AbstractNode
125-
) where {D,ID,F1,F2,G,H}
124+
mapreducer::TreeMapreducer{D,ID}, tree::AbstractNode
125+
) where {D,ID}
126126
quote
127127
key = ID <: Dict ? objectid(tree) : nothing
128128
if ID <: Dict && haskey(mapreducer.id_map, key)
@@ -369,11 +369,13 @@ function map(
369369
result_type::Type{RT}=Nothing;
370370
break_sharing::Val{BS}=Val(false),
371371
) where {F<:Function,RT,BS}
372-
if RT == Nothing
373-
return map(f, collect(tree; break_sharing=Val(BS)))
374-
else
375-
return filter_map(Returns(true), f, tree, result_type; break_sharing=Val(BS))
376-
end
372+
return _map(f, tree, result_type, Val(BS))
373+
end
374+
function _map(f::F, tree::AbstractNode, ::Type{Nothing}, ::Val{BS}) where {F<:Function,BS}
375+
return map(f, collect(tree; break_sharing=Val(BS)))
376+
end
377+
function _map(f::F, tree::AbstractNode, ::Type{RT}, ::Val{BS}) where {F<:Function,RT,BS}
378+
return filter_map(Returns(true), f, tree, RT; break_sharing=Val(BS))
377379
end
378380

379381
"""

test/test_node_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ end
5353
idx_max = 1
5454
tree = Node{Float64,D}(; op=idx_max, children=(tree, x[1], x[2], x[3])) # max
5555
end
56-
@test Interfaces.test(NodeInterface, Node, tree)
56+
@test Interfaces.test(NodeInterface, Node, [tree])
5757
end
5858
end
5959
end

0 commit comments

Comments
 (0)