Skip to content

Commit

Permalink
improve Revise checking
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Dec 13, 2024
1 parent e458abe commit 5f1f200
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Stipple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1022,15 +1022,16 @@ macro kwredef(expr)

T = t[n]

# in the first run the datatype is not yet defined
# this is also the case when Revise registers the code, therefore we need
# to make sure that the generated name is always identical for first definition
already_defined = T isa DataType || isdefined(__module__, T) && @eval(__module__, $T) isa DataType

if isa(T, Expr) && T.head == Symbol(".")
T = (split(string(T), '.')[end] |> Symbol)
end

# in the first run the datatype is not yet defined
# this is also the case when Revise registers the code, therefore we need
# to make sure that the generated name is always identical for first definition
called_first_time = !isa(T, DataType)
t[n] = T_new = called_first_time ? Symbol(T, :def) : gensym(T)
t[n] = T_new = already_defined ? gensym(T) : Symbol(T, :def)

quote
Base.@kwdef $expr
Expand Down

0 comments on commit 5f1f200

Please sign in to comment.