Skip to content

Cannot read variable in local scope #70

@raythurnvoid

Description

@raythurnvoid
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions