Skip to content

Commit d0a521f

Browse files
committed
generated function with less dependencies
This commit removes the dependency of generated function to IdSet because it is not yet defined during the bootstrap stages. By doing this, we can avoid the world age issues and use @generated function in abstractarray.jl.
1 parent 18f7fe9 commit d0a521f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

base/expr.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,15 +1684,23 @@ function generated_body_to_codeinfo(ex::Expr, defmod::Module, isva::Bool)
16841684
end
16851685
ci.isva = isva
16861686
code = ci.code
1687-
bindings = IdSet{Core.Binding}()
1687+
bindings = Core.svec()
16881688
for i = 1:length(code)
16891689
stmt = code[i]
16901690
if isa(stmt, GlobalRef)
1691-
push!(bindings, convert(Core.Binding, stmt))
1691+
# plain loop is used rather than fancy `any` or `IdSet` to avoid world-age issues
1692+
# if we want to use generated function during the early bootstrap stage when
1693+
# these functions are not available. (e.g., using `@generated` in `abstractarray.jl`)
1694+
for x in bindings
1695+
if x === stmt
1696+
continue
1697+
end
1698+
end
1699+
bindings = Core.svec(bindings..., convert(Core.Binding, stmt))
16921700
end
16931701
end
16941702
if !isempty(bindings)
1695-
ci.edges = Core.svec(bindings...)
1703+
ci.edges = bindings
16961704
end
16971705
return ci
16981706
end

0 commit comments

Comments
 (0)