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

JuliaLang / julia / #38004
77%

Build:
DEFAULT BRANCH: master
Ran 08 Feb 2025 08:31AM UTC
Jobs 1
Files 211
Run time 1min
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

08 Feb 2025 04:15AM UTC coverage: 19.401% (-3.6%) from 23.008%
#38004

push

local

web-flow
Inference: propagate struct initialization info on `setfield!` (#57222)

When a variable has a field set with `setfield!(var, field, value)`,
inference now assumes that this specific field is defined and may for
example constant-propagate `isdefined(var, field)` as `true`.
`PartialStruct`, the lattice element used to encode this information,
still has a few limitations in terms of what it may represent (it cannot
represent mutable structs with non-contiguously defined fields yet),
further work on extending it would increase the impact of this change.

Consider the following function:
```julia
julia> function f()
           a = A(1)
           setfield!(a, :y, 2)
           invokelatest(identity, a)
           isdefined(a, :y) && return 1.0
           a
       end
f (generic function with 1 method)
```

Here is before on `master`:
```julia
julia> @code_typed f()
CodeInfo(
1 ─ %1 = %new(Main.A, 1)::A
│          builtin Main.setfield!(%1, :y, 2)::Int64
│        dynamic builtin (Core._call_latest)(identity, %1)::Any
│   %4 =   builtin Main.isdefined(%1, :y)::Bool
└──      goto #3 if not %4
2 ─      return 1.0
3 ─      return %1
) => Union{Float64, A}
```

And after this PR:
```julia
julia> @code_typed f()
CodeInfo(
1 ─ %1 = %new(Main.A, 1)::A
│          builtin Main.setfield!(%1, :y, 2)::Int64
│        dynamic builtin (Core._call_latest)(identity, %1)::Any
└──      return 1.0
) => Float64
```

---------

Co-authored-by: Cédric Belmant <cedric.belmant@juliahub.com>

9440 of 48658 relevant lines covered (19.4%)

95900.84 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
44.72
-0.5% base/genericmemory.jl
1
26.1
-0.34% base/strings/io.jl
1
4.62
-0.77% base/filesystem.jl
1
41.18
-13.82% base/strings/lazy.jl
1
9.87
-0.66% base/strings/cstring.jl
1
52.7
-1.35% base/libuv.jl
1
28.13
-3.13% base/gcutils.jl
1
10.34
-1.72% base/scopedvalues.jl
1
22.77
-0.21% base/io.jl
1
17.72
-0.32% base/promotion.jl
1
67.65
-1.92% base/uuid.jl
1
60.44
-1.1% base/iddict.jl
1
17.95
-2.56% base/some.jl
1
3.88
-0.78% base/floatfuncs.jl
1
27.71
-0.43% base/reduce.jl
1
7.87
-1.12% base/rounding.jl
1
48.68
-1.32% base/pointer.jl
1
6.06
-1.52% base/number.jl
2
1.1
-0.44% base/math.jl
2
69.49
-3.39% base/condition.jl
2
6.67
-2.22% base/multimedia.jl
2
30.63
-0.9% base/path.jl
2
14.79
-1.41% base/stat.jl
2
35.53
-1.02% base/operators.jl
2
8.76
-0.92% base/indices.jl
3
8.97
-0.96% base/arrayshow.jl
3
57.81
-0.63% base/dict.jl
3
6.4
-1.74% base/strings/unicode.jl
3
19.13
-0.73% base/set.jl
4
59.42
-5.8% base/Base.jl
4
3.25
-0.33% base/methodshow.jl
4
30.09
-1.85% base/parse.jl
4
68.18
-18.18% base/locks-mt.jl
4
44.55
-3.64% base/version.jl
5
17.05
-0.68% base/sort.jl
5
25.42
-6.86% base/env.jl
5
9.87
-0.67% base/range.jl
5
17.27
0.0% base/Base_compiler.jl
5
36.53
-2.99% base/int.jl
6
40.0
-24.0% base/pkgid.jl
7
53.09
-4.32% base/essentials.jl
7
44.3
-3.07% base/bitset.jl
7
31.25
-21.88% base/ordering.jl
7
30.91
-1.88% base/boot.jl
8
13.88
-2.85% base/lock.jl
9
15.99
-2.31% base/regex.jl
9
21.27
-1.54% base/iterators.jl
9
53.89
-5.0% base/cmd.jl
10
0.0
-7.87% base/shell.jl
10
45.45
-18.18% base/idset.jl
11
15.62
-0.96% base/bitarray.jl
11
17.68
-22.32% base/util.jl
12
40.42
-5.0% base/logging/logging.jl
13
14.72
-7.98% base/sysinfo.jl
13
44.59
-8.78% base/strings/substring.jl
13
16.47
-0.97% base/abstractarray.jl
13
6.25
-3.63% base/deprecated.jl
15
21.62
-2.7% base/bool.jl
16
28.04
-7.48% base/iostream.jl
16
34.48
-3.23% base/runtime_internals.jl
20
14.2
-3.94% base/intfuncs.jl
21
18.53
-3.02% base/errorshow.jl
21
0.0
-14.89% base/ryu/utils.jl
21
30.83
-4.15% base/task.jl
23
42.55
-2.18% base/stream.jl
25
28.94
-4.87% base/client.jl
27
53.79
-2.47% base/array.jl
29
4.83
-20.0% base/invalidation.jl
31
8.47
-23.73% base/refpointer.jl
33
10.47
-38.37% base/error.jl
33
47.98
-16.67% base/channels.jl
34
34.83
-10.21% base/iobuffer.jl
36
33.68
-18.65% base/initdefs.jl
37
33.54
-25.49% base/stacktraces.jl
38
48.71
-4.16% stdlib/Test/src/Test.jl
44
0.0
-13.06% base/ryu/shortest.jl
45
15.63
-15.63% base/strings/search.jl
52
19.83
-14.53% base/strings/util.jl
52
18.88
-3.34% base/char.jl
67
27.3
-21.78% base/process.jl
69
29.21
-4.49% base/strings/basic.jl
69
18.95
-0.53% base/namedtuple.jl
74
19.07
-19.07% base/file.jl
115
15.99
-0.63% base/tuple.jl
142
3.08
-72.82% base/staticdata.jl
192
16.11
-8.89% base/show.jl
199
7.32
-6.9% base/float.jl
204
2.17
0.0% base/gmp.jl
303
1.42
-0.0% base/mpfr.jl
327
9.22
0.0% base/multidimensional.jl
378
11.33
-17.02% base/loading.jl
Jobs
ID Job ID Ran Files Coverage
1 #38004.1 08 Feb 2025 08:31AM UTC 211
19.4
Source Files on build #38004
  • Tree
  • List 211
  • Changed 141
  • Source Changed 0
  • Coverage Changed 95
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • b682f496 on github
  • Prev Build on master
  • Next Build on master
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