Skip to content

Commit a680324

Browse files
authored
update to upstream lowering change (#72)
Lowering for a closure construct has been changed by JuliaLang/julia#44974 as like: ```julia julia> using LoweredCodeUtils, JuliaInterpreter julia> ex = quote function fouter(x) finner(::Float16) = 2x return finner(Float16(1)) end end quote #= REPL[19]:2 =# function fouter(x) #= REPL[19]:2 =# #= REPL[19]:3 =# finner(::Float16) = begin #= REPL[19]:3 =# 2x end #= REPL[19]:4 =# return finner(Float16(1)) end end julia> Core.eval(@__MODULE__, ex) fouter (generic function with 1 method) julia> Frame(@__MODULE__, ex).framecode.src ``` ```diff diff --git a/before.jl b/after.jl index 24b26cb..728d385 100644 --- a/before.jl +++ b/after.jl @@ -12,9 +12,9 @@ CodeInfo( │ const var"#finner#2" │ Core.TypeVar(:x, Core.Any) │ %4 = Core._structtype(Main, Symbol("#finner#2"), Core.svec(%3), Core.svec(:x), Core.svec(), false, 1) +│ Core._setsuper!(%4, Core.Function) │ var"#finner#2" = %4 -│ Core._setsuper!(var"#finner#2", Core.Function) -│ Core._typebody!(var"#finner#2", Core.svec(%3)) +│ Core._typebody!(%4, Core.svec(%3)) └── return nothing ))) │ ($(QuoteNode(Core.svec)))(var"#finner#2", Float16) ```
1 parent 8708c89 commit a680324

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/utils.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ function isanonymous_typedef(stmt)
7676
if isa(stmt, CodeInfo)
7777
src = stmt # just for naming consistency
7878
length(src.code) >= 4 || return false
79-
stmt = src.code[end-1]
80-
(isexpr(stmt, :call) && is_global_ref(stmt.args[1], Core, :_typebody!)) || return false
81-
name = (stmt::Expr).args[2]::Symbol
79+
@static if VERSION v"1.9.0-DEV.391"
80+
stmt = src.code[end-2]
81+
isexpr(stmt, :(=)) || return false
82+
name = stmt.args[1]
83+
isa(name, Symbol) || return false
84+
else
85+
stmt = src.code[end-1]
86+
isexpr(stmt, :call) || return false
87+
is_global_ref(stmt.args[1], Core, :_typebody!) || return false
88+
name = stmt.args[2]::Symbol
89+
end
8290
return startswith(String(name), "#")
8391
end
8492
return false

0 commit comments

Comments
 (0)