Skip to content

Commit 1ff98a5

Browse files
authored
Walk to imports in isconst(::GlobalRef) (#57563)
This restores 1.11 behavior. However, I find this function a bit problematic, since it is asking whether the binding is `constant` in a particular sense, but not whether it is `const` (in the sense of having been declared with the keyword or equivalent), so the shortening is confusing. However, we don't need to address that now. Fixes #57475.
1 parent bfe9c2f commit 1ff98a5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/module.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,8 +1370,7 @@ JL_DLLEXPORT int jl_globalref_is_const(jl_globalref_t *gr)
13701370
if (!b)
13711371
b = jl_get_module_binding(gr->mod, gr->name, 1);
13721372
jl_binding_partition_t *bpart = jl_get_binding_partition(b, jl_current_task->world_age);
1373-
if (!bpart)
1374-
return 0;
1373+
jl_walk_binding_inplace(&b, &bpart, jl_current_task->world_age);
13751374
return jl_bkind_is_some_constant(jl_binding_kind(bpart));
13761375
}
13771376

test/reflection.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ not_const = 1
110110
@test isconst(@__MODULE__, :a_const) == true
111111
@test isconst(Base, :pi) == true
112112
@test isconst(@__MODULE__, :pi) == true
113+
@test isconst(GlobalRef(@__MODULE__, :pi)) == true
113114
@test isconst(@__MODULE__, :not_const) == false
114115
@test isconst(@__MODULE__, :is_not_defined) == false
115116

0 commit comments

Comments
 (0)