SciML / SciML/RuntimeGeneratedFunctions.jl

Cannot read variable in local scope

Open
#70 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.