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

JuliaLang / julia / 1554

08 Jan 2026 06:52PM UTC coverage: 76.664% (+0.04%) from 76.623%
1554

push

buildkite

web-flow
[JuliaLowering] Fix-up always-defined check in `is_valid_body_ir_argument` (#60602)

This was slightly mis-translated from the flisp side:
```scheme
    (define (valid-body-ir-argument? aval)
      (or (valid-ir-argument? aval)
          (and (symbol? aval) ; Arguments are always defined slots
               (or (memq aval (lam:args lam))
                   (let ((vi (get vinfo-table aval #f)))
                     (and vi (vinfo:never-undef vi)))))))
```

Noticed in
https://github.com/JuliaLang/julia/pull/60567#discussion_r2672556146

62618 of 81679 relevant lines covered (76.66%)

23088815.22 hits per line

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

93.46
/stdlib/Markdown/src/parse/util.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
const whitespace = " \t\r"
4

5
"""
6
Skip any leading whitespace. Returns io.
7
"""
8
function skipwhitespace(io::IO; newlines = true)
685,132✔
9
    while !eof(io) && (peek(io, Char) in whitespace || (newlines && peek(io) == UInt8('\n')))
685,096✔
10
        read(io, Char)
181,202✔
11
    end
181,202✔
12
    return io
342,566✔
13
end
14

15
"""
16
Skip any leading blank lines. Returns the number skipped.
17
"""
18
function skipblank(io::IO)
255,197✔
19
    start = position(io)
255,197✔
20
    i = 0
255,197✔
21
    for c in readeach(io, Char)
479,203✔
22
        c == '\n' && (start = position(io); i+=1; continue)
322,966✔
23
        c == '\r' && (start = position(io); i+=1; continue)
309,236✔
24
        c in whitespace || break
309,233✔
25
    end
205,132✔
26
    seek(io, start)
510,394✔
27
    return i
255,197✔
28
end
29

30
"""
31
Return true if the line contains only (and, unless allowempty,
32
at least one of) the characters given.
33
"""
34
function linecontains(io::IO, chars; allow_whitespace = true,
432,664✔
35
                                     eat = true,
36
                                     allowempty = false)
37
    start = position(io)
216,332✔
38
    l = readline(io)
216,332✔
39
    length(l) == 0 && return allowempty
216,332✔
40

41
    result = allowempty
138,256✔
42
    for c in l
276,494✔
43
        c in whitespace && (allow_whitespace ? continue : (result = false; break))
143,782✔
44
        c in chars && (result = true; continue)
138,229✔
45
        result = false; break
138,229✔
46
    end
11,061✔
47
    !(result && eat) && seek(io, start)
276,485✔
48
    return result
138,256✔
49
end
50

51
blankline(io::IO; eat = true) =
432,664✔
52
    linecontains(io, "",
53
                 allow_whitespace = true,
54
                 allowempty = true,
55
                 eat = eat)
56

57
"""
58
Test if the stream starts with the given string.
59
`eat` specifies whether to advance on success (true by default).
60
`padding` specifies whether leading whitespace should be ignored.
61
"""
62
function startswith(stream::IO, s::AbstractString; eat = true, padding = false, newlines = true)
4,252,192✔
63
    start = position(stream)
2,126,096✔
64
    padding && skipwhitespace(stream, newlines = newlines)
2,126,096✔
65
    result = true
2,126,096✔
66
    for char in s
4,252,192✔
67
        !eof(stream) && read(stream, Char) == char ||
2,344,116✔
68
            (result = false; break)
1,924,381✔
69
    end
637,755✔
70
    !(result && eat) && seek(stream, start)
4,050,501✔
71
    return result
2,126,096✔
72
end
73

74
function startswith(stream::IO, c::AbstractChar; eat = true)
1,495,928✔
75
    if !eof(stream) && peek(stream) == UInt8(c)
1,487,827✔
76
        eat && read(stream, Char)
287,656✔
77
        return true
287,656✔
78
    else
79
        return false
1,200,171✔
80
    end
81
end
82

83
function startswith(stream::IO, ss::Vector{<:AbstractString}; kws...)
×
84
    any(s->startswith(stream, s; kws...), ss)
×
85
end
86

87
function matchstart(stream::IO, r::Regex; eat = true, padding = false)
755,254✔
88
    @assert Base.startswith(r.pattern, "^")
377,627✔
89
    start = position(stream)
377,627✔
90
    padding && skipwhitespace(stream)
377,627✔
91
    line = readline(stream)
377,627✔
92
    seek(stream, start)
755,254✔
93
    m = match(r, line)
377,627✔
94
    if eat && m !== nothing
377,627✔
95
        for i in 1:length(m.match)
135,861✔
96
            read(stream, Char)
151,632✔
97
        end
167,403✔
98
    end
99
    return m
377,627✔
100
end
101

102
"""
103
Executes the block of code, and if the return value is `nothing`,
104
returns the stream to its initial position.
105
"""
106
function withstream(f, stream)
179,672✔
107
    pos = position(stream)
2,249,902✔
108
    result = f()
2,250,160✔
109
    (result ≡ nothing || result ≡ false) && seek(stream, pos)
3,745,061✔
110
    return result
2,249,902✔
111
end
112

113
"""
114
Consume the standard allowed markdown indent of
115
three spaces. Returns false if there are more than
116
three present.
117
"""
118
function eatindent(io::IO, n = 3)
119
    withstream(io) do
931,648✔
120
        m = 0
422,590✔
121
        while startswith(io, ' ') m += 1 end
605,688✔
122
        return m <= n
422,590✔
123
    end
124
end
125

126
"""
127
Read the stream until startswith(stream, delim)
128
The delimiter is consumed but not included.
129
Returns nothing and resets the stream if delim is
130
not found.
131
"""
132
function readuntil(stream::IO, delimiter; newlines = false, match = nothing)
175,757✔
133
    withstream(stream) do
175,757✔
134
        buffer = IOBuffer()
174,816✔
135
        count = 0
174,816✔
136
        while !eof(stream)
1,620,571✔
137
            if startswith(stream, delimiter)
1,619,839✔
138
                if count == 0
174,517✔
139
                    return takestring!(buffer)
173,875✔
140
                else
141
                    count -= 1
642✔
142
                    write(buffer, delimiter)
642✔
143
                    continue
642✔
144
                end
145
            end
146
            char = read(stream, Char)
1,445,322✔
147
            char == match && (count += 1)
1,445,322✔
148
            !newlines && char == '\n' && break
1,445,322✔
149
            write(buffer, char)
1,445,113✔
150
        end
1,445,755✔
151
    end
152
end
153

154
# TODO: refactor this. If we're going to assume
155
# the delimiter is a single character + a minimum
156
# repeat we may as well just pass that into the
157
# function.
158

159
"""
160
Parse a symmetrical delimiter which wraps words.
161
i.e. `*word word*` but not `*word * word`.
162
`repeat` specifies whether the delimiter can be repeated.
163
Escaped delimiters are not yet supported.
164
"""
165
function parse_inline_wrapper(stream::IO, delimiter::AbstractString; rep = false)
168,244✔
166
    delimiter, nmin = string(delimiter[1]), length(delimiter)
168,244✔
167
    withstream(stream) do
84,122✔
168
        if position(stream) >= 1
84,122✔
169
            # check the previous byte isn't a delimiter
170
            skip(stream, -1)
90,484✔
171
            (read(stream, Char) in delimiter) && return nothing
45,242✔
172
        end
173
        n = nmin
83,030✔
174
        startswith(stream, delimiter^n) || return nothing
162,875✔
175
        while startswith(stream, delimiter); n += 1; end
3,977✔
176
        !rep && n > nmin && return nothing
3,185✔
177
        !eof(stream) && peek(stream, Char) in whitespace && return nothing
2,786✔
178

179
        buffer = IOBuffer()
2,672✔
180
        for char in readeach(stream, Char)
5,233✔
181
            write(buffer, char)
36,758✔
182
            if !(char in whitespace || char == '\n' || char in delimiter) && startswith(stream, delimiter^n)
70,320✔
183
                trailing = 0
2,028✔
184
                while startswith(stream, delimiter); trailing += 1; end
2,163✔
185
                trailing == 0 && return takestring!(buffer)
2,028✔
186
                write(buffer, delimiter ^ (n + trailing))
108✔
187
            end
188
        end
34,838✔
189
    end
190
end
191

192
function showrest(io::IO)
×
193
    start = position(io)
×
194
    show(read(io, String))
×
195
    println()
×
196
    seek(io, start)
×
197
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