Skip to content

Commit 31a94ef

Browse files
committed
Don't search for links inside :copyast expressions
1 parent 5bc1095 commit 31a94ef

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/codeedges.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function add_links!(target::Pair{<:Any,Links}, @nospecialize(stmt), cl::CodeLink
284284
cl.namesuccs[stmt] = namestore = Links()
285285
end
286286
push!(namestore, targetid)
287-
elseif isa(stmt, Expr)
287+
elseif isa(stmt, Expr) && stmt.head !== :copyast
288288
arng = 1:length(stmt.args)
289289
if stmt.head === :call
290290
f = stmt.args[1]

test/codeedges.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ end
219219
isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod3(stmt)&&stmt.args[1]===:Struct,false), src, edges) # initially mark only the constructor
220220
selective_eval_fromstart!(frame, isrequired, true)
221221
@test isa(ModSelective.Struct([1,2,3]), ModSelective.Struct{Int})
222+
# Keyword constructor (this generates :copyast expressions)
223+
ex = quote
224+
struct KWStruct
225+
x::Int
226+
y::Float32
227+
z::String
228+
function KWStruct(; x::Int=1, y::Float32=1.0f0, z::String="hello")
229+
return new(x, y, z)
230+
end
231+
end
232+
end
233+
frame = JuliaInterpreter.prepare_thunk(ModSelective, ex)
234+
src = frame.framecode.src
235+
edges = CodeEdges(src)
236+
isrequired = minimal_evaluation(stmt->(LoweredCodeUtils.ismethod3(stmt),false), src, edges) # initially mark only the constructor
237+
selective_eval_fromstart!(frame, isrequired, true)
238+
kws = ModSelective.KWStruct(y=5.0f0)
239+
@test kws.y === 5.0f0
222240

223241
# Anonymous functions
224242
ex = :(max_values(T::Union{map(X -> Type{X}, Base.BitIntegerSmall_types)...}) = 1 << (8*sizeof(T)))

0 commit comments

Comments
 (0)