Struct initialization error

I am having an error that I don’t understand. The code works on the REPL but it doesn’t when called from the terminal (after being compiled with Comonicon):

There is this struct called State, and it’s constructor that accepts keyword arguments. I am able to initialize and use it on the REPL, but on the terminal it throws this error, which is crazy because it is complaining that a method does not exist when it exists (as it shows me it exists). What am I missing? Can it be a world age bug?

An MWE.

1 Like

The code is rather big and on a private repo, so I will try to put the corresponding parts here, but I don’t know if it is going to be enough.

function state_factory(initial_conditions::NamedTuple)
    state_signature = generate_state_signature(initial_conditions)

    fields = map(x -> Meta.parse(x), split(state_signature))

    return quote
        struct State
            $(fields...)
            timestep::Int64
            substep::Int64

            function State($(fields...), timestep::Int64, substep::Int64)
                new($(fields...), timestep::Int64, substep::Int64)
            end

            State(; $(fields...), timestep::Int64 = 1, substep::Int64 = 1) = State($(fields...), timestep::Int64, substep::Int64)
        end
    end
end

function generate_state_signature(initial_conditions::NamedTuple)
    state_signature = ""

    for (variable, value) in pairs(initial_conditions)
        type = typeof(value)
        state_signature *= "$variable::$type "
    end

    return state_signature
end

This functions gets eval’d based on the named tuple. The constructor should accept keyword arguments, and it does on the REPL, but not on the terminal.