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

**URL:** <https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947>\
**Category:** General Usage\
**Tags:** precompilation, constructors, multiple-dispatch, world\_age\
**Created:** [March 2, 2026, 1:08am UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947 "2026-03-02T01:08:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnaak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cnaak/32/10287_2.png) [@cnaak](https://discourse.julialang.org/u/cnaak)\
**Post date:** [March 2, 2026, 1:08am UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/1 "2026-03-02T01:08:38Z")

</div>

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 `@eval`s), I’ve got the world age warning (future error).

MWE:

```julia
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:

```julia-auto
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
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

```julia
example(all::S) where S<:AbstractString = invokelatest(example(split(all, ' ')...))

```

did not work at all and further introduce the error:

```julia
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

```

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [March 2, 2026, 1:32am UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/2 "2026-03-02T01:32:07Z")

</div>

> [@cnaak](#):
>
> 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),

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.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [March 2, 2026, 3:13am UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/3 "2026-03-02T03:13:43Z")

</div>

I pasted that in an old `HelloWorld` tutorial package, activated it, and imported it for a quick experiment on v1.12.5 (Windows). I’m seeing the 2 method definition warnings, but I’m not seeing the world age warning, so I’m assuming there’s some difference from `GNTParsings` or its environment. The 2 method definition warnings went by pretty fast so I haphazardly threw in a `print("Hello precompile")` before the export line. It showed up 3 times adjacent to the 2 warnings; the last run could be the non-precompiling `eval` that lets the subsequent `example` calls work, so precompilation appears to be happening before each warning.

---

<div class="post-metadata">

**Author:** ![cnaak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cnaak/32/10287_2.png) [@cnaak](https://discourse.julialang.org/u/cnaak)\
**Post date:** [March 2, 2026, 1:56pm UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/4 "2026-03-02T13:56:31Z")

</div>

Ahh, snap! because of the default argument in

```julia
function example(pos::S, per::C='-') where {S<:AbstractString, C<:AbstractChar}

```

Tried removing it and it worked (no warnings at all). Thank you!

That’s what happens when you switch among different languages of completely different paradigms!

It should be nevertheless noted that the world age warning placed me in the wrong track (likely my fault, as I should’ve taken more heed to the previous method overwriting warning).

---

<div class="post-metadata">

**Author:** ![cnaak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cnaak/32/10287_2.png) [@cnaak](https://discourse.julialang.org/u/cnaak)\
**Post date:** [March 2, 2026, 2:01pm UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/5 "2026-03-02T14:01:28Z")

</div>

Thanks for your effort in reconstructing the scenario and testing!

You added to the world age issue by pointing it’s absence in Windows (I use a Linux box), and yes, we’re running the same version of julia: Version 1.12.5 (2026-02-09)

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [March 2, 2026, 2:51pm UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947/6 "2026-03-02T14:51:51Z")

</div>

> [@cnaak](#):
>
> It should be nevertheless noted that the world age warning placed me in the wrong track (likely my fault, as I should’ve taken more heed to the previous method overwriting warning).

I do agree, but it would be helpful if you could provide a full MWE. Claude was unable to reproduce it as stated.
