From dd34e12221bb05113ea2b73b5a5410cae908e6dc Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Tue, 30 Jan 2024 20:18:21 +0900 Subject: [PATCH] JETAnalyzer: disable `bail_out_const_call` To get nicer error reports. --- src/analyzers/jetanalyzer.jl | 7 +++++++ test/analyzers/test_jetanalyzer.jl | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/analyzers/jetanalyzer.jl b/src/analyzers/jetanalyzer.jl index 463bfbd5e..35f8edb51 100644 --- a/src/analyzers/jetanalyzer.jl +++ b/src/analyzers/jetanalyzer.jl @@ -275,6 +275,13 @@ function CC.add_call_backedges!( sv::InferenceState) end +@static if VERSION ≥ v"1.11.0-DEV.1284" +CC.bail_out_const_call(::JETAnalyzer, ::MethodCallResult, ::StmtInfo, ::MethodMatch, ::InferenceState) = false +else +CC.const_prop_enabled(::JETAnalyzer, ::MethodMatch, ::InferenceState) = true +CC.bail_out_const_call(::JETAnalyzer, ::MethodCallResult, ::StmtInfo, ::InferenceState) = false +end + # TODO Reasons about error found by [semi-]concrete evaluation: # For now JETAnalyzer allows the regular constant-prop' only, # unless the analyzed effects are proven to be `:nothrow`. diff --git a/test/analyzers/test_jetanalyzer.jl b/test/analyzers/test_jetanalyzer.jl index 00fdb08f8..a165f810a 100644 --- a/test/analyzers/test_jetanalyzer.jl +++ b/test/analyzers/test_jetanalyzer.jl @@ -810,6 +810,16 @@ end x.y = "bar" end end + let # Note: on v1.11 and above, we need to disable `bail_out_const_call` + # in order to get a nicer report for this case + result = report_call((Float64,)) do x + x.num + end + @test only(get_reports_with_test(result)) isa BuiltinErrorReport + test_builtinerror_compatibility(result) do + (0.0).num + end + end end @testset "getfield analysis" begin