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

JuliaLang / julia / #37342 / 1
77%
master: 77%

Build:
DEFAULT BRANCH: master
Ran 19 Nov 2022 11:38AM UTC
Files 385
Run time 12s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

19 Nov 2022 06:22AM UTC coverage: 93.121% (+0.2%) from 92.962%
#37342.1

push

local

web-flow
inference: implement type-based alias analysis to refine constrained field (#41199)

This commit tries to propagate constraints imposed on object fields, e.g.:
```julia
struct SomeX{T}
    x::Union{Nothing,T}
end
mutable struct MutableSomeX{T}
    const x::Union{Nothing,T}
end

let # o1::SomeX{T}, o2::MutableSomeX{T}
    if !isnothing(o1.x)
        # now inference knows `o1.x::T` here
        ...
        if !isnothing(o2.x)
            # now inference knows `o2.x::T` here
            ...
        end
    end
end
```

The idea is that we can make `isa` and `===` propagate constraint
imposed on an object field if the _identity_ of that object.
We can have such a lattice element that wraps return type of abstract
`getfield` call together with the object _identity_, and then we can
form a conditional constraint that propagates the refinement information
imposed on the object field when we see `isa`/`===` applied the return
value of the preceding `getfield` call.

So this PR defines the new lattice element called `MustAlias` (and also
`InterMustAlias`, which just works in a similar way to `InterConditional`),
which may be formed upon `getfield` inference to hold the retrieved type
of the field and track the _identity_ of the object (in inference,
"object identity" can be represented as a `SlotNumber`).
This PR also implements the new logic in `abstract_call_builtin` so that
`isa` and `===` can form a conditional constraint (i.e. `Conditional`)
from `MustAlias`-argument that may later refine the wrapped object to
`PartialStruct` that holds the refined field type information.

One important note here is, `MustAlias` expects the invariant that the
field of wrapped slot object never changes. The biggest limitation with
this invariant is that it can't propagate constraints imposed on mutable
fields, because inference currently doesn't have a precise (per-object)
knowledge of memory effect.

80644 of 86601 relevant lines covered (93.12%)

18315169.48 hits per line

Source Files on job #37342.1
  • Tree
  • List 0
  • Changed 184
  • Source Changed 0
  • Coverage Changed 184
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 37342
  • 1d8f7e07 on github
  • Prev Job for on master (##37341.1)
  • Next Job for on master (##37344.1)
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