Skip to content

Commit 845a52b

Browse files
authored
fix #39862, error in inference when trying to apply a non-type (#40047)
1 parent 046e2cf commit 845a52b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ function apply_type_tfunc(@nospecialize(headtypetype), @nospecialize args...)
11441144
end
11451145
return allconst ? Const(ty) : Type{ty}
11461146
end
1147-
istuple = (headtype == Tuple)
1147+
istuple = isa(headtype, Type) && (headtype == Tuple)
11481148
if !istuple && !isa(headtype, UnionAll)
11491149
return Union{}
11501150
end

test/compiler/inference.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,3 +2985,8 @@ g38888() = S38888(Base.inferencebarrier(3), nothing)
29852985
# issue #38971
29862986
f28971() = (1, [2,3]...)::Tuple{Int,Int,Int}
29872987
@test @inferred(Tuple{Int,Vararg{Int}}, f28971()) == (1, 2, 3)
2988+
2989+
# issue #39862
2990+
let f() = sin{Int}()
2991+
@test Base.return_types(f, ()) == Any[Union{}]
2992+
end

0 commit comments

Comments
 (0)