Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer a missing method as returning Union{} #20866

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1385,10 +1385,6 @@ function abstract_call_gf_by_type(f::ANY, atype::ANY, sv::InferenceState)
add_mt_backedge(ftname.mt, argtype, sv)
update_valid_age!(min_valid[1], max_valid[1], sv)
end
if isempty(x)
# TODO: this is needed because type intersection is wrong in some cases
return Any
end
#print("=> ", rettype, "\n")
return rettype
end
Expand Down
3 changes: 3 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,6 @@ Base.@pure function a20704(x)
end
aa20704(x) = x(nothing)
@test code_typed(aa20704, (typeof(a20704),))[1][1].pure

# missing method should be inferred as Union{}, ref https://github.com/JuliaLang/julia/issues/20033#issuecomment-282228948
@test Base.return_types(f -> f(1), (typeof((x::String) -> x),)) == Any[Union{}]
2 changes: 1 addition & 1 deletion test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ gstr = GenericString("12")
@test ind2chr(gstr,2)==2

# issue #10307
@test typeof(map(Int16,AbstractString[])) == Vector{Int16}
@test typeof(map(x -> parse(Int16, x), AbstractString[])) == Vector{Int16}

for T in [Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128]
for i in [typemax(T), typemin(T)]
Expand Down