• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #38002

06 Feb 2025 06:14AM UTC coverage: 20.322% (-2.4%) from 22.722%
#38002

push

local

web-flow
bpart: Fully switch to partitioned semantics (#57253)

This is the final PR in the binding partitions series (modulo bugs and
tweaks), i.e. it closes #54654 and thus closes #40399, which was the
original design sketch.

This thus activates the full designed semantics for binding partitions,
in particular allowing safe replacement of const bindings. It in
particular allows struct redefinitions. This thus closes
timholy/Revise.jl#18 and also closes #38584.

The biggest semantic change here is probably that this gets rid of the
notion of "resolvedness" of a binding. Previously, a lot of the behavior
of our implementation depended on when bindings were "resolved", which
could happen at basically an arbitrary point (in the compiler, in REPL
completion, in a different thread), making a lot of the semantics around
bindings ill- or at least implementation-defined. There are several
related issues in the bugtracker, so this closes #14055 closes #44604
closes #46354 closes #30277

It is also the last step to close #24569.
It also supports bindings for undef->defined transitions and thus closes
#53958 closes #54733 - however, this is not activated yet for
performance reasons and may need some further optimization.

Since resolvedness no longer exists, we need to replace it with some
hopefully more well-defined semantics. I will describe the semantics
below, but before I do I will make two notes:

1. There are a number of cases where these semantics will behave
slightly differently than the old semantics absent some other task going
around resolving random bindings.
2. The new behavior (except for the replacement stuff) was generally
permissible under the old semantics if the bindings happened to be
resolved at the right time.

With all that said, there are essentially three "strengths" of bindings:

1. Implicit Bindings: Anything implicitly obtained from `using Mod`, "no
binding", plus slightly more exotic corner cases around conflicts

2. Weakly declared bindin... (continued)

11 of 111 new or added lines in 7 files covered. (9.91%)

1273 existing lines in 68 files now uncovered.

9908 of 48755 relevant lines covered (20.32%)

105126.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/base/pkgid.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
struct PkgId
4
    uuid::Union{UUID,Nothing}
5
    name::String
6

7
    PkgId(u::UUID, name::AbstractString) = new(UInt128(u) == 0 ? nothing : u, name)
1,859✔
8
    PkgId(::Nothing, name::AbstractString) = new(nothing, name)
29✔
9
end
10
PkgId(name::AbstractString) = PkgId(nothing, name)
29✔
11

12
function PkgId(m::Module, name::String = String(nameof(moduleroot(m))))
12✔
13
    uuid = UUID(ccall(:jl_module_uuid, NTuple{2, UInt64}, (Any,), m))
24✔
14
    UInt128(uuid) == 0 ? PkgId(name) : PkgId(uuid, name)
21✔
15
end
16

17
==(a::PkgId, b::PkgId) = a.uuid == b.uuid && a.name == b.name
42,334✔
18

19
function hash(pkg::PkgId, h::UInt)
20
    h += 0xc9f248583a0ca36c % UInt
×
21
    h = hash(pkg.uuid, h)
40✔
22
    h = hash(pkg.name, h)
23✔
23
    return h
23✔
24
end
25

26
show(io::IO,  ::MIME"text/plain", pkg::PkgId) =
×
27
    print(io, pkg.name, " [", pkg.uuid === nothing ? "top-level" : pkg.uuid, "]")
28

29
function binpack(pkg::PkgId)
×
30
    io = IOBuffer()
×
31
    write(io, UInt8(0))
×
32
    uuid = pkg.uuid
×
33
    write(io, uuid === nothing ? UInt128(0) : UInt128(uuid))
×
34
    write(io, pkg.name)
×
35
    return String(take!(io))
×
36
end
37

38
function binunpack(s::String)
UNCOV
39
    io = IOBuffer(s)
×
UNCOV
40
    z = read(io, UInt8)
×
UNCOV
41
    @assert z === 0x00
×
UNCOV
42
    uuid = read(io, UInt128)
×
UNCOV
43
    name = read(io, String)
×
UNCOV
44
    return PkgId(UUID(uuid), name)
×
45
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc