Skip to content

Commit 0079acf

Browse files
committed
fix: constructor from explicit eltype
1 parent 0514598 commit 0079acf

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Node.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,18 @@ end
299299
end
300300

301301
@inline function node_factory_type(::Type{N}, ::Type{T1}, ::Type{T2}) where {N,T1,T2}
302-
if T1 === Undefined && N isa UnionAll
302+
if T1 === Undefined && !defines_eltype(N)
303303
T2
304304
elseif T1 === Undefined
305305
eltype(N)
306-
elseif N isa UnionAll
306+
elseif !defines_eltype(N)
307307
T1
308308
else
309309
eltype(N)
310310
end
311311
end
312+
defines_eltype(::Type{<:AbstractExpressionNode}) = false
313+
defines_eltype(::Type{<:AbstractExpressionNode{T}}) where {T} = true
312314
#! format: on
313315

314316
function (::Type{N})(

test/test_base_2.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using DynamicExpressions, Random
1313

1414
x = Node{Float64}(; feature=1)
15+
@test x isa Node{Float64}
1516

1617
# We can also create values, using `val`:
1718
const_1 = Node{Float64}(; val=1.0)

test/test_parametric_expression.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ end
349349
@test val isa Float64
350350
@test grad isa NamedTuple
351351
@test grad.tree isa DynamicExpressions.ChainRulesModule.NodeTangent{
352-
Float64,ParametricNode{Float64},Vector{Float64}
352+
Float64,<:ParametricNode{Float64},Vector{Float64}
353353
}
354354
@test grad.metadata._data.parameters isa Matrix{Float64}
355355

0 commit comments

Comments
 (0)