Skip to content

Commit 5af916f

Browse files
authored
Fix show for tangent types with free diff level (#139)
Follows up #136
1 parent 5373279 commit 5af916f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/tangent.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,20 @@ wrapper_name(::Type{<:AbstractZeroBundle}) = "AbstractZeroBundle"
261261

262262
function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N, B}}) where {N,B}
263263
print(io, wrapper_name(T))
264-
print(io, "{$N, ")
264+
print(io, @isdefined(N) ? "{$N, " : "{N, ")
265265
show(io, B)
266266
print(io, "}")
267267
end
268268

269269
function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N}}) where {N}
270270
print(io, wrapper_name(T))
271-
print(io, "{$N}")
271+
@isdefined(N) && print(io, "{$N}")
272272
end
273273

274274
function Base.show(io::IO, t::AbstractZeroBundle{N}) where N
275275
print(io, wrapper_name(typeof(t)))
276-
print(io, "{$N}(")
276+
@isdefined(N) && print(io, "{$N}")
277+
print(io, "(")
277278
show(io, t.primal)
278279
print(io, ")")
279280
end

test/tangent.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ using Test
1818
@test repr(ZeroBundle{1}) == "ZeroBundle{1}"
1919
@test repr(ZeroBundle{1, Float64}) == "ZeroBundle{1, Float64}"
2020

21+
@test repr((ZeroBundle{N, Float64} where N).body) == "ZeroBundle{N, Float64}"
22+
2123
@test repr(typeof(DNEBundle{1}(getfield))) == "DNEBundle{1, typeof(getfield)}"
2224
end
2325
end

0 commit comments

Comments
 (0)