Skip to content

Commit

Permalink
Revert "Improve typesubtract for tuples (#35600)" (#37562)
Browse files Browse the repository at this point in the history
This reverts commit cf0c3e0.

(cherry picked from commit b18647e)
  • Loading branch information
vtjnash authored and KristofferC committed Oct 21, 2020
1 parent 7c7e8b6 commit 489ae0a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
9 changes: 0 additions & 9 deletions base/compiler/typeutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ function typesubtract(@nospecialize(a), @nospecialize(b))
if isa(a, Union)
return Union{typesubtract(a.a, b),
typesubtract(a.b, b)}
elseif a isa DataType
if b isa DataType
if a.name === b.name === Tuple.name && length(a.types) == length(b.types)
ta = switchtupleunion(a)
if length(ta) > 1
return typesubtract(Union{ta...}, b)
end
end
end
end
return a # TODO: improve this bound?
end
Expand Down
41 changes: 0 additions & 41 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2562,47 +2562,6 @@ end

@test map(>:, [Int], [Int]) == [true]

# issue 35566
module Issue35566
function step(acc, x)
xs, = acc
y = x > 0.0 ? x : missing
if y isa eltype(xs)
ys = push!(xs, y)
else
ys = vcat(xs, [y])
end
return (ys,)
end

function probe(y)
if y isa Tuple{Vector{Missing}}
return Val(:missing)
else
return Val(:expected)
end
end

function _foldl_iter(rf, val::T, iter, state) where {T}
while true
ret = iterate(iter, state)
ret === nothing && break
x, state = ret
y = rf(val, x)
if y isa T
val = y
else
return probe(y)
end
end
return Val(:expected)
end

f() = _foldl_iter(step, (Missing[],), [0.0], 1)
end
@test Core.Compiler.typesubtract(Tuple{Union{Int,Char}}, Tuple{Char}) == Tuple{Int}
@test Base.return_types(Issue35566.f) == [Val{:expected}]

# constant prop through keyword arguments
_unstable_kw(;x=1,y=2) = x == 1 ? 0 : ""
_use_unstable_kw_1() = _unstable_kw(x = 2)
Expand Down

0 comments on commit 489ae0a

Please sign in to comment.