Skip to content

Commit

Permalink
make get_binding_type more precise for consts
Browse files Browse the repository at this point in the history
replaces #44232
  • Loading branch information
simeonschaub committed Mar 15, 2022
1 parent ee6115b commit 04d160a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ JL_DLLEXPORT jl_value_t *jl_binding_type(jl_module_t *m, jl_sym_t *var)
JL_UNLOCK(&m->lock);
if (b == NULL)
return jl_nothing;
if (b->constp) {
jl_value_t *val = jl_atomic_load_relaxed(&b->value);
return val ? jl_typeof(val) : jl_nothing;
}
jl_value_t *ty = jl_atomic_load_relaxed(&b->ty);
return ty ? ty : jl_nothing;
}
Expand Down
3 changes: 3 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1112,3 +1112,6 @@ end
@testset "Base/timing.jl" begin
@test Base.jit_total_bytes() >= 0
end

const I_AM_A_CONSTANT_INT = 1
@test Core.get_binding_type(@__MODULE__, :I_AM_A_CONSTANT_INT) == Int

0 comments on commit 04d160a

Please sign in to comment.