Skip to content

Commit

Permalink
Within-module eval can break precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Oct 22, 2023
1 parent 4777e60 commit f7d6bdd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/stylemacro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ macro styled_str(raw_content::String)
(i, i + state.offset[] + 1,
if needseval
:(Pair{Symbol, Any}(:face, $face))
elseif Base.generating_output()
Pair{Symbol, Any}(:face, Core.eval(__module__, face))
else
Pair{Symbol, Any}(:face, eval(face))
end))
Expand Down Expand Up @@ -666,7 +668,7 @@ macro styled_str(raw_content::String)
run_state_machine!(state)
if !isempty(state.errors)
throw(MalformedStylingMacro(state.content, state.errors))
elseif state.interpolated[]
elseif state.interpolated[] || Base.generating_output()
:(annotatedstring($(state.parts...)))
else
annotatedstring(map(eval, state.parts)...) |> Base.annotatedstring_optimize!
Expand Down

0 comments on commit f7d6bdd

Please sign in to comment.