From c5e5c97c57f79fed8be57bbf2b0df6abdf16df9b Mon Sep 17 00:00:00 2001 From: Sam Schweigel Date: Wed, 30 Apr 2025 11:14:12 -0700 Subject: [PATCH] Recognize Core.declare_const in get_lhs_rhs This is the minimal change to get Revise working with JuliaLang/julia#57470. Comparison of lowering of `const foo = 1`: 1.11: Expr(:const, :foo), Expr(:(=), :foo, 1) (with edge 2 -> 1) 1.12: Expr(:const, :foo, 1) 1.13: Expr(:call, Core.declare_const, :foo, 1) --- src/codeedges.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/codeedges.jl b/src/codeedges.jl index 5e63b29..e6cede2 100644 --- a/src/codeedges.jl +++ b/src/codeedges.jl @@ -203,10 +203,12 @@ function get_lhs_rhs(@nospecialize stmt) if isexpr(stmt, :(=)) return Pair{Any,Any}(stmt.args[1], stmt.args[2]) elseif isexpr(stmt, :const) && length(stmt.args) == 2 + # TODO: remove lowered :const when Julia min compat >= 1.13 return Pair{Any,Any}(stmt.args[1], stmt.args[2]) elseif isexpr(stmt, :call) && length(stmt.args) == 4 f = stmt.args[1] - if is_global_ref_egal(f, :setglobal!, Core.setglobal!) + # TODO: remove isdefined when Julia min compat >= 1.13 + if is_global_ref_egal(f, :setglobal!, Core.setglobal!) || @static isdefined(Core, :declare_const) && is_global_ref_egal(f, :declare_const, Core.declare_const) mod = stmt.args[2] mod isa Module || return nothing name = stmt.args[3]