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

JuliaLang / julia / #37527

pending completion
#37527

push

local

web-flow
make `IRShow.method_name` inferrable (#49607)

18 of 18 new or added lines in 3 files covered. (100.0%)

68710 of 81829 relevant lines covered (83.97%)

33068903.12 hits per line

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

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

3
export @var
4

5
struct Binding
6
    mod::Module
7
    var::Symbol
8

9
    function Binding(m::Module, v::Symbol)
465✔
10
        # Normalise the binding module for module symbols so that:
11
        #   Binding(Base, :Base) === Binding(Main, :Base)
12
        m = nameof(m) === v ? parentmodule(m) : m
465✔
13
        new(Base.binding_module(m, v), v)
468✔
14
    end
15
end
16

17
bindingexpr(x) = Expr(:call, Binding, splitexpr(x)...)
462✔
18

19
defined(b::Binding) = isdefined(b.mod, b.var)
465✔
20
resolve(b::Binding) = getfield(b.mod, b.var)
462✔
21

22
function splitexpr(x::Expr)
5✔
23
    isexpr(x, :macrocall) ? splitexpr(x.args[1]) :
5✔
24
    isexpr(x, :.)         ? (x.args[1], x.args[2]) :
25
    error("Invalid @var syntax `$x`.")
26
end
27
splitexpr(s::Symbol) = Expr(:macrocall, getfield(Base, Symbol("@__MODULE__")), nothing), quot(s)
457✔
28
splitexpr(r::GlobalRef) = r.mod, quot(r.name)
×
29
splitexpr(other)     = error("Invalid @var syntax `$other`.")
×
30

31
macro var(x)
32
    esc(bindingexpr(x))
33
end
34

35
function Base.show(io::IO, b::Binding)
×
36
    if b.mod === Base.active_module()
×
37
        print(io, b.var)
×
38
    else
39
        print(io, b.mod, '.', Base.isoperator(b.var) ? ":" : "", b.var)
×
40
    end
41
end
42

43
aliasof(b::Binding)     = defined(b) ? (a = aliasof(resolve(b), b); defined(a) ? a : b) : b
×
44
aliasof(d::DataType, b) = Binding(d.name.module, d.name.name)
×
45
aliasof(λ::Function, b) = (m = typeof(λ).name.mt; Binding(m.module, m.name))
4✔
46
aliasof(m::Module,   b) = Binding(m, nameof(m))
1✔
47
aliasof(other,       b) = b
×
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

© 2025 Coveralls, Inc