From 0c044578e09ee3e94f25b9dbbbfbf31c426027f4 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Sun, 1 Sep 2024 05:31:04 +0900 Subject: [PATCH] fix new type instability from `getindex(::String, r::UnitRange{Int})` (#55625) --- base/compiler/typeinfer.jl | 5 +++-- base/strings/string.jl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index e2f2a1f2cc975f..315a068e611fe9 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -864,7 +864,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize end end if ccall(:jl_get_module_infer, Cint, (Any,), method.module) == 0 && !generating_output(#=incremental=#false) - add_remark!(interp, caller, "Inference is disabled for the target module") + add_remark!(interp, caller, "[typeinf_edge] Inference is disabled for the target module") return EdgeCallResult(Any, Any, nothing, Effects()) end if !is_cached(caller) && frame_parent(caller) === nothing @@ -897,7 +897,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize end frame = InferenceState(result, cache_mode, interp) # always use the cache for edge targets if frame === nothing - add_remark!(interp, caller, "Failed to retrieve source") + add_remark!(interp, caller, "[typeinf_edge] Failed to retrieve source") # can't get the source for this, so we know nothing if cache_mode == CACHE_MODE_GLOBAL engine_reject(interp, ci) @@ -918,6 +918,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize return EdgeCallResult(frame.bestguess, exc_bestguess, edge, effects, volatile_inf_result) elseif frame === true # unresolvable cycle + add_remark!(interp, caller, "[typeinf_edge] Unresolvable cycle") return EdgeCallResult(Any, Any, nothing, Effects()) end # return the current knowledge about this cycle diff --git a/base/strings/string.jl b/base/strings/string.jl index f5abbead34bd10..90d6e5b26ccd31 100644 --- a/base/strings/string.jl +++ b/base/strings/string.jl @@ -208,7 +208,7 @@ end i = i′ @inbounds l = codeunit(s, i) (l < 0x80) | (0xf8 ≤ l) && return i+1 - @assert l >= 0xc0 + @assert l >= 0xc0 "invalid codeunit" end # first continuation byte (i += 1) > n && return i