Skip to content

Commit

Permalink
fix some internals being called
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonProtter committed Jan 25, 2024
1 parent d995391 commit 04ca3ce
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Base.schedule(t, val; error=false) = (schedule(t.t, val; error); t)
macro spawn(ex)
tp = QuoteNode(:default)

letargs = Base._lift_one_interp!(ex)
letargs = _lift_one_interp!(ex)

thunk = Base.replace_linenums!(:(()->($(esc(ex)))), __source__)
thunk = replace_linenums!(:(()->($(esc(ex)))), __source__)
var = esc(Base.sync_varname) # This is for the @sync macro which sets a local variable whose name is
# the symbol bound to Base.sync_varname
# I asked on slack and this is apparently safe to consider a public API
Expand Down Expand Up @@ -80,4 +80,25 @@ function _lift_one_interp_helper(expr::Expr, in_quote_context, letargs)
expr
end

# Copied from base rather than calling it directly because who knows if it'll change in the future
replace_linenums!(ex, ln::LineNumberNode) = ex
function replace_linenums!(ex::Expr, ln::LineNumberNode)
if ex.head === :block || ex.head === :quote
# replace line number expressions from metadata (not argument literal or inert) position
map!(ex.args, ex.args) do @nospecialize(x)
isa(x, Expr) && x.head === :line && length(x.args) == 1 && return Expr(:line, ln.line)
isa(x, Expr) && x.head === :line && length(x.args) == 2 && return Expr(:line, ln.line, ln.file)
isa(x, LineNumberNode) && return ln
return x
end
end
# preserve any linenums inside `esc(...)` guards
if ex.head !== :escape
for subex in ex.args
subex isa Expr && replace_linenums!(subex, ln)
end
end
return ex
end

end # module Internals

2 comments on commit 04ca3ce

@MasonProtter
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/99571

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 04ca3ce5844e3a634fbc684810388b4e05c2549f
git push origin v0.1.0

Please sign in to comment.