Skip to content

Commit

Permalink
Fix importing over a previously defined constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Jun 27, 2024
1 parent 6282a92 commit aa4b302
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *asname,
else {
if (eq_bindings(bpart, bto, jl_current_task->world_age)) {
// already imported - potentially upgrade to _IMPORTED or _EXPLICIT
btopart->kind = (explici != 0) ? BINDING_KIND_IMPORTED : BINDING_KIND_EXPLICIT;
if (jl_bpart_is_some_import(btopart))
btopart->kind = (explici != 0) ? BINDING_KIND_IMPORTED : BINDING_KIND_EXPLICIT;
// TODO: This will need to be versioned when partitioned
}
else if (jl_bpart_is_some_import(btopart)) {
Expand Down
10 changes: 10 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3872,3 +3872,13 @@ module BarDualImport
import ..FooDualImport
import ..FooDualImport.FooDualImport
end

# Test trying to define a constant and then importing the same constant
const ImportConstant = 1
module ImportConstantTestModule
using Test
const ImportConstant = 1
import ..ImportConstant
@test ImportConstant == 1
@test isconst(@__MODULE__, :ImportConstant)
end

0 comments on commit aa4b302

Please sign in to comment.