Skip to content

Commit 24aec43

Browse files
committed
fix: type assertion issue in constructor
1 parent 33e5966 commit 24aec43

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Node.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ end
292292
@inline function node_factory(
293293
::Type{N}, ::Type, ::Nothing, ::Nothing, op::Integer, children::Union{Tuple,AbstractVector}, allocator::F,
294294
) where {N<:AbstractExpressionNode,F}
295-
T = promote_type(map(eltype, children)...) # Always prefer existing nodes, so we don't mess up references from conversion
295+
T = defines_eltype(N) ? eltype(N) : promote_type(map(eltype, children)...)
296+
defines_eltype(N) && @assert T === promote_type(T, map(eltype, children)...)
296297
D2 = length(children)
297298
@assert D2 <= max_degree(N)
298299
NT = with_type_parameters(N, T)

test/test_tree_construction.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ end
126126
x = N{BigFloat}(; feature=1)
127127
@test_throws AssertionError N{Float32}(1, x)
128128
@test N{BigFloat}(1, x) == N(1, x)
129+
@test N{BigFloat}(1, x) isa N{BigFloat}
129130
@test typeof(N(1, x, N{Float32}(; val=1))) <: N{BigFloat}
130131
@test typeof(N(1, N{Float32}(; val=1), x)) <: N{BigFloat}
131132
end

0 commit comments

Comments
 (0)