Skip to content

Commit 0b3826c

Browse files
committed
Test fix.
Some tests depend on the bug fixed. For example, the `convert` test for `NamedTuple` works because `Tuple{Type{NamedTuple{(:a,),Tuple{I}} where I<:Unsigned}} <: Tuple{Type{NT}} where {names, T<:Tuple, NT<:NamedTuple{names,T}}` on master.
1 parent 5a318eb commit 0b3826c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

base/namedtuple.jl

+8
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ function convert(::Type{NT}, nt::NamedTuple{names}) where {names, T<:Tuple, NT<:
196196
return NT1(T1(nt))::NT1::NT
197197
end
198198

199+
function convert(::Type{NT}, nt::NamedTuple{names}) where {names, NT<:NamedTuple{names}}
200+
# converting abstract NT to an abstract Tuple type, to a concrete NT1, is not straightforward, so this could just be an error, but we define it anyways
201+
# _tuple_error(NT, nt)
202+
T1 = Tuple{ntuple(i -> fieldtype(NT, i), Val(length(names)))...}
203+
NT1 = NamedTuple{names, T1}
204+
return NT1(T1(nt))::NT1::NT
205+
end
206+
199207
if nameof(@__MODULE__) === :Base
200208
Tuple(nt::NamedTuple) = (nt...,)
201209
(::Type{T})(nt::NamedTuple) where {T <: Tuple} = (t = Tuple(nt); t isa T ? t : convert(T, t)::T)

stdlib/LinearAlgebra/src/bidiag.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Matrix(A::Bidiagonal{T}) where {T} = Matrix{promote_type(T, typeof(zero(T)))}(A)
214214
Array(A::Bidiagonal) = Matrix(A)
215215
promote_rule(::Type{Matrix{T}}, ::Type{<:Bidiagonal{S}}) where {T,S} =
216216
@isdefined(T) && @isdefined(S) ? Matrix{promote_type(T,S)} : Matrix
217-
promote_rule(::Type{Matrix}, ::Type{<:Bidiagonal}) = Matrix
217+
promote_rule(::Type{<:Matrix}, ::Type{<:Bidiagonal}) = Matrix
218218

219219
#Converting from Bidiagonal to Tridiagonal
220220
function Tridiagonal{T}(A::Bidiagonal) where T

0 commit comments

Comments
 (0)