SciML / SciML/RuntimeGeneratedFunctions.jl
Cannot read variable in local scope
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 112
- Forks
- 19
- Avg merge
- 6h 11m
- Merged PRs (30d)
- 9
Description
using DataFrames
using Dates
using RuntimeGeneratedFunctions
RuntimeGeneratedFunctions.init(@__MODULE__)
w = Base.get_world_counter()
function Base.show(io::IO, mime::MIME"text/plain", df::AbstractDataFrame; kwargs...)
fn = @RuntimeGeneratedFunction(:(
(v, i::Int, j::Int) -> begin
println(mime) # <- This fails
typeof(v) <: DateTime ? Dates.format(v, "dd-mm-yyyy HH:MM") : v
end
))
Base.invoke_in_world(w, Base.show,
io,
mime,
df;
formatters=fn,
kwargs...
)
end
The result of the code above is:
UndefVarError: mime not defined
Am i doing something wrong?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Julia example in the issue and trace the RuntimeGeneratedFunction entry point used to build the formatter closure. Determine how the local mime binding is handled, and consider the issue complete when the example can access that binding without raising UndefVarError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100