World age warning (no @eval) on constructor of different dispatch

Updated to julia-1.12 and started a new package. As soon as I defined my first struct with more than one external constructor (nothing fancy, no @evals), I’ve got the world age warning (future error).

MWE:

struct example
    pos::String
    per::Char
    # Internal (validating) constructor
    function example(pos::S, per::C='-') where {S<:AbstractString, C<:AbstractChar}
        @assert pos in ("RA", "RD")
        @assert per in "-123"
        return new(pos, per)
    end
end

export example

# The first external constructor works fine
example(pos::S, par::S) where S<:AbstractString = example(pos, par...)
# Next line raises warning
example(all::S) where S<:AbstractString = example(split(all, ' ')...)

Basically these constructors allows for convenient syntax in the particular field of application, which does not pertain to the issue/MWE.

Upon precompiling (using in the REPL), the last line, which defines the only one-argument constructor (which should be fine given julia’s multiple dispatch), causes a WARNING: Method definition to be issued (twice!) saying the validating constructor got redefined (which doesn’t make sense, due to different dispatch), along with:

WARNING: Detected access to binding `XXXX.example` in a world prior to its definition world.
  Julia 1.12 has introduced more strict world age semantics for global bindings.
  !!! This code may malfunction under Revise.
  !!! This code will error in future versions of Julia.
Hint: Add an appropriate `invokelatest` around the access to this binding.
To make this warning an error, and hence obtain a stack trace, use `julia --depwarn=error`.

Since it will become an error, I did some research and my case seems NOT to relate with the things I see (i) in the documentation, (ii) julia’s open issues, or (iii) this forum.

It issues warning but it works as intended:

julia> example("RA", '1')
example("RA", '1')

julia> example("RA", "1")
example("RA", '1')

julia> example("RA 1")
example("RA", '1')
  1. What is really the issue?
  2. What would be the “appropriate” invokelatests syntax to fix this as per suggestion? As
example(all::S) where S<:AbstractString = invokelatest(example(split(all, ' ')...))

did not work at all and further introduce the error:

julia> example("RA 1")
ERROR: MethodError: objects of type example are not callable
The object of type `example` exists, but no method is defined for this combination of argument types when
 trying to treat it as a callable object.
Stacktrace:
 [1] example(all::String)
   @ GNTParsings /home/BACK/trendy/local/dev/GNTParsings.jl/src/types.jl:21
 [2] top-level scope
   @ REPL[4]:1

You’re overwriting the one argument version of the internal constructor. As for why you’re getting the world age warning, that’s probably a bug with the warning for this case running in the wrong world age.