Skip to content

Commit 15b044b

Browse files
authored
Fix incorrect computation of return_type of itr (#287)
* Fix incorrect computation of return_type of `itr` The `itr` return type was assumed to be always the same as the first element. This is false for many objects, such as Tuple. Additionally, it was using a private API (Core.Compiler and Core.Compiler.return_type) which are not stable across versions of Julia and may return weird and unpredictable answers. Switch to using the API in Base for this. * Update collect.jl
1 parent 3b38c22 commit 15b044b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/collect.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function collect_structarray(itr; initializer = default_initializer)
4141
end
4242

4343
function _collect_structarray(itr::T, ::Nothing, ax; initializer = default_initializer) where {T}
44-
S = Core.Compiler.return_type(first, Tuple{T})
44+
S = Base.@default_eltype itr
4545
return initializer(S, something(ax, (Base.OneTo(0),)))
4646
end
4747

0 commit comments

Comments
 (0)