diff --git a/src/module.c b/src/module.c index ad4613c2d5c56..50d4d90c7f4bb 100644 --- a/src/module.c +++ b/src/module.c @@ -782,9 +782,10 @@ JL_DLLEXPORT jl_value_t *jl_get_binding_type(jl_module_t *m, jl_sym_t *var) if (b == NULL) return jl_nothing; jl_walk_binding_inplace(&b, &bpart, jl_current_task->world_age); - if (jl_bkind_is_some_guard(jl_binding_kind(bpart))) + enum jl_partition_kind kind = jl_binding_kind(bpart); + if (jl_bkind_is_some_guard(kind) || kind == BINDING_KIND_DECLARED) return jl_nothing; - if (jl_bkind_is_some_constant(jl_binding_kind(bpart))) { + if (jl_bkind_is_some_constant(kind)) { // TODO: We would like to return the type of the constant, but // currently code relies on this returning any to bypass conversion // before an attempted assignment to a constant. diff --git a/test/core.jl b/test/core.jl index 55f3268e61eb5..fd607cc86f1d5 100644 --- a/test/core.jl +++ b/test/core.jl @@ -8463,3 +8463,11 @@ function f57315() return 1 end @test_throws UndefVarError(:flag_2, :local) f57315() + +# issue #57446 +module GlobalAssign57446 + using Test + global theglobal + (@__MODULE__).theglobal = 1 + @test theglobal == 1 +end