Skip to content

Commit b0a0faa

Browse files
committed
test return type inference
1 parent 85c4649 commit b0a0faa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/core.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8191,6 +8191,29 @@ end
81918191
@test_throws "expected Union{$Int, Symbol}" getfield((1,2), Int8(1))
81928192
end
81938193

8194+
@testset "constructing functions should have perfect return type inference" begin
8195+
for (type, func) in (
8196+
(Bool, Base._Bool),
8197+
(Int, Base._Int),
8198+
(Int8, Base._Int8),
8199+
(Int16, Base._Int16),
8200+
(Int32, Base._Int32),
8201+
(Int64, Base._Int64),
8202+
(Int128, Base._Int128),
8203+
(UInt, Base._UInt),
8204+
(UInt8, Base._UInt8),
8205+
(UInt16, Base._UInt16),
8206+
(UInt32, Base._UInt32),
8207+
(UInt64, Base._UInt64),
8208+
(UInt128, Base._UInt128),
8209+
(Char, Base._Char),
8210+
(String, Base._String),
8211+
)
8212+
@test isconcretetype(type) # meta test
8213+
@test type === Base.infer_return_type(x -> func(x))
8214+
end
8215+
end
8216+
81948217
# Correct isdefined error for isdefined of Module of Int fld
81958218
f_isdefined_one(@nospecialize(x)) = isdefined(x, 1)
81968219
@test (try; f_isdefined_one(@__MODULE__); catch err; err; end).got === 1

0 commit comments

Comments
 (0)