diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 641b753365b34..5bec048d60259 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -5090,6 +5090,7 @@ f(x) = yt(x) (check-top-level e) (let ((val (make-ssavalue))) (emit `(= ,val ,e)) + (emit `(latestworld)) (if tail (emit-return tail val)) val)) diff --git a/test/worlds.jl b/test/worlds.jl index db9a48ae45197..c44f8bd2894c8 100644 --- a/test/worlds.jl +++ b/test/worlds.jl @@ -598,3 +598,21 @@ function f() end end @test_throws ErrorException("importing Random into M57965 conflicts with an existing global") M57965.f() + +# issue #59429 - world age semantics with toplevel in macros +module M59429 +using Test +macro new_enum(T::Symbol, args...) + esc(quote + @enum $T $(args...) + function Base.hash(x::$T, h::UInt) + rand(UInt) + end + end) +end + +@new_enum Foo59429 bar59429 baz59429 + +# Test that the hash function works without world age issues +@test hash(bar59429, UInt(0)) isa UInt +end