@@ -7,6 +7,8 @@ using Test
77include (" setup_Compiler.jl" )
88include (" irutils.jl" )
99
10+ const coverage_enabled = (Base. JLOptions (). code_coverage != 0 )
11+
1012# tests for Compiler correctness and precision
1113using . Compiler: Conditional, ⊑
1214isdispatchelem (@nospecialize x) = ! isa (x, Type) || Compiler. isdispatchelem (x)
@@ -5187,19 +5189,19 @@ end
51875189invoke_concretized1 (a:: Int ) = a > 0 ? :int : nothing
51885190invoke_concretized1 (a:: Integer ) = a > 0 ? " integer" : nothing
51895191# check if `invoke(invoke_concretized1, Tuple{Integer}, ::Int)` is foldable
5190- @test Base. infer_effects ((Int,)) do a
5192+ @test ( Base. infer_effects ((Int,)) do a
51915193 @invoke invoke_concretized1 (a:: Integer )
5192- end |> Compiler. is_foldable
5194+ end |> Compiler. is_foldable) broken = coverage_enabled
51935195@test Base. return_types () do
51945196 @invoke invoke_concretized1 (42 :: Integer )
51955197end |> only === String
51965198
51975199invoke_concretized2 (a:: Int ) = a > 0 ? :int : nothing
51985200invoke_concretized2 (a:: Integer ) = a > 0 ? :integer : nothing
51995201# check if `invoke(invoke_concretized2, Tuple{Integer}, ::Int)` is foldable
5200- @test Base. infer_effects ((Int,)) do a
5202+ @test ( Base. infer_effects ((Int,)) do a
52015203 @invoke invoke_concretized2 (a:: Integer )
5202- end |> Compiler. is_foldable
5204+ end |> Compiler. is_foldable) broken = coverage_enabled
52035205@test let
52045206 Base. Experimental. @force_compile
52055207 @invoke invoke_concretized2 (42 :: Integer )
@@ -5298,7 +5300,7 @@ type_level_recurse_entry() = Val{type_level_recurse1(1)}()
52985300f_no_bail_effects_any (x:: Any ) = x
52995301f_no_bail_effects_any (x:: NamedTuple{(:x,), Tuple{Any}} ) = getfield (x, 1 )
53005302g_no_bail_effects_any (x:: Any ) = f_no_bail_effects_any (x)
5301- @test Compiler. is_foldable_nothrow (Base. infer_effects (g_no_bail_effects_any, Tuple{Any}))
5303+ @test Compiler. is_foldable_nothrow (Base. infer_effects (g_no_bail_effects_any, Tuple{Any})) broken = coverage_enabled
53025304
53035305# issue #48374
53045306@test (() -> Union{<: Nothing })() == Nothing
@@ -6132,65 +6134,65 @@ end == Val{true}
61326134end == Val
61336135
61346136# 2. getfield modeling for partial struct
6135- @test Base. infer_effects ((Any,Any); optimize= false ) do a, b
6137+ @test ( Base. infer_effects ((Any,Any); optimize= false ) do a, b
61366138 getfield (PartiallyInitialized1 (a, b), :b )
6137- end |> Compiler. is_nothrow
6139+ end |> Compiler. is_nothrow) broken = coverage_enabled
61386140@test Base. infer_effects ((Any,Any,Symbol,); optimize= false ) do a, b, f
61396141 getfield (PartiallyInitialized1 (a, b), f, #= boundscheck=# false )
61406142end |> ! Compiler. is_nothrow
6141- @test Base. infer_effects ((Any,Any,Any); optimize= false ) do a, b, c
6143+ @test ( Base. infer_effects ((Any,Any,Any); optimize= false ) do a, b, c
61426144 getfield (PartiallyInitialized1 (a, b, c), :c )
6143- end |> Compiler. is_nothrow
6144- @test Base. infer_effects ((Any,Any,Any,Symbol); optimize= false ) do a, b, c, f
6145+ end |> Compiler. is_nothrow) broken = coverage_enabled
6146+ @test ( Base. infer_effects ((Any,Any,Any,Symbol); optimize= false ) do a, b, c, f
61456147 getfield (PartiallyInitialized1 (a, b, c), f, #= boundscheck=# false )
6146- end |> Compiler. is_nothrow
6147- @test Base. infer_effects ((Any,Any); optimize= false ) do a, b
6148+ end |> Compiler. is_nothrow) broken = coverage_enabled
6149+ @test ( Base. infer_effects ((Any,Any); optimize= false ) do a, b
61486150 getfield (PartiallyInitialized2 (a, b), :b )
6149- end |> Compiler. is_nothrow
6151+ end |> Compiler. is_nothrow) broken = coverage_enabled
61506152@test Base. infer_effects ((Any,Any,Symbol,); optimize= false ) do a, b, f
61516153 getfield (PartiallyInitialized2 (a, b), f, #= boundscheck=# false )
61526154end |> ! Compiler. is_nothrow
6153- @test Base. infer_effects ((Any,Any,Any); optimize= false ) do a, b, c
6155+ @test ( Base. infer_effects ((Any,Any,Any); optimize= false ) do a, b, c
61546156 getfield (PartiallyInitialized2 (a, b, c), :c )
6155- end |> Compiler. is_nothrow
6156- @test Base. infer_effects ((Any,Any,Any,Symbol); optimize= false ) do a, b, c, f
6157+ end |> Compiler. is_nothrow) broken = coverage_enabled
6158+ @test ( Base. infer_effects ((Any,Any,Any,Symbol); optimize= false ) do a, b, c, f
61576159 getfield (PartiallyInitialized2 (a, b, c), f, #= boundscheck=# false )
6158- end |> Compiler. is_nothrow
6160+ end |> Compiler. is_nothrow) broken = coverage_enabled
61596161
61606162# isdefined-Conditionals
6161- @test Base. infer_effects ((Base. RefValue{Any},)) do x
6163+ @test ( Base. infer_effects ((Base. RefValue{Any},)) do x
61626164 if isdefined (x, :x )
61636165 return getfield (x, :x )
61646166 end
6165- end |> Compiler. is_nothrow
6166- @test Base. infer_effects ((Base. RefValue{Any},)) do x
6167+ end |> Compiler. is_nothrow) broken = coverage_enabled
6168+ @test ( Base. infer_effects ((Base. RefValue{Any},)) do x
61676169 if isassigned (x)
61686170 return x[]
61696171 end
6170- end |> Compiler. is_nothrow
6172+ end |> Compiler. is_nothrow) broken = coverage_enabled
61716173@test Base. infer_effects ((Any,Any); optimize= false ) do a, c
61726174 x = PartiallyInitialized2 (a)
61736175 x. c = c
61746176 if isdefined (x, :c )
61756177 return x. b
61766178 end
61776179end |> ! Compiler. is_nothrow
6178- @test Base. infer_effects ((PartiallyInitialized2,); optimize= false ) do x
6180+ @test ( Base. infer_effects ((PartiallyInitialized2,); optimize= false ) do x
61796181 if isdefined (x, :b )
61806182 if isdefined (x, :c )
61816183 return x. c
61826184 end
61836185 return x. b
61846186 end
61856187 return nothing
6186- end |> Compiler. is_nothrow
6187- @test Base. infer_effects ((Bool,Int,); optimize= false ) do c, b
6188+ end |> Compiler. is_nothrow) broken = coverage_enabled
6189+ @test ( Base. infer_effects ((Bool,Int,); optimize= false ) do c, b
61886190 x = c ? PartiallyInitialized1 (true ) : PartiallyInitialized1 (true , b)
61896191 if isdefined (x, :b )
61906192 return Val (x. a), x. b
61916193 end
61926194 return nothing
6193- end |> Compiler. is_nothrow
6195+ end |> Compiler. is_nothrow) broken = coverage_enabled
61946196
61956197# refine `undef` information from `@isdefined` check
61966198function isdefined_nothrow (c, x)
@@ -6203,7 +6205,7 @@ function isdefined_nothrow(c, x)
62036205 end
62046206 return zero (Int)
62056207end
6206- @test Compiler. is_nothrow (Base. infer_effects (isdefined_nothrow, (Bool,Int)))
6208+ @test Compiler. is_nothrow (Base. infer_effects (isdefined_nothrow, (Bool,Int))) broken = coverage_enabled
62076209@test ! any (first (only (code_typed (isdefined_nothrow, (Bool,Int)))). code) do @nospecialize x
62086210 Meta. isexpr (x, :throw_undef_if_not )
62096211end
@@ -6251,9 +6253,9 @@ end == TypeError
62516253# nothrow modeling for `invoke` calls
62526254f_invoke_nothrow (:: Number ) = :number
62536255f_invoke_nothrow (:: Int ) = :int
6254- @test Base. infer_effects ((Int,)) do x
6256+ @test ( Base. infer_effects ((Int,)) do x
62556257 @invoke f_invoke_nothrow (x:: Number )
6256- end |> Compiler. is_nothrow
6258+ end |> Compiler. is_nothrow) broken = coverage_enabled
62576259@test Base. infer_effects ((Char,)) do x
62586260 @invoke f_invoke_nothrow (x:: Number )
62596261end |> ! Compiler. is_nothrow
@@ -6392,16 +6394,16 @@ end
63926394
63936395global global_decl_defined
63946396global_decl_defined = 42
6395- @test Base. infer_effects (; interp= AssumeBindingsStaticInterp ()) do
6397+ @test ( Base. infer_effects (; interp= AssumeBindingsStaticInterp ()) do
63966398 global global_decl_defined
63976399 return global_decl_defined
6398- end |> Compiler. is_nothrow
6400+ end |> Compiler. is_nothrow) broken = coverage_enabled
63996401global global_decl_defined2:: Int
64006402global_decl_defined2 = 42
6401- @test Base. infer_effects (; interp= AssumeBindingsStaticInterp ()) do
6403+ @test ( Base. infer_effects (; interp= AssumeBindingsStaticInterp ()) do
64026404 global global_decl_defined2
64036405 return global_decl_defined2
6404- end |> Compiler. is_nothrow
6406+ end |> Compiler. is_nothrow) broken = coverage_enabled
64056407
64066408@eval get_exception () = $ (Expr (:the_exception ))
64076409@test Base. infer_return_type () do
0 commit comments