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

JuliaLang / julia / #37917

27 Sep 2024 02:34AM UTC coverage: 87.243% (-0.5%) from 87.72%
#37917

push

local

web-flow
inference: add missing `TypeVar` handling for `instanceof_tfunc` (#55884)

I thought these sort of problems had been addressed by d60f92c, but it
seems some were missed. Specifically, `t.a` and `t.b` from `t::Union`
could be `TypeVar`, and if they are passed to a subroutine or recursed
without being unwrapped or rewrapped, errors like JuliaLang/julia#55882
could occur.

This commit resolves the issue by calling `unwraptv` in the `Union`
handling within `instanceof_tfunc`. I also found a similar issue inside
`nfields_tfunc`, so that has also been fixed, and test cases have been
added. While I haven't been able to make up a test case specifically for
the fix in `instanceof_tfunc`, I have confirmed that this commit
certainly fixes the issue reported in JuliaLang/julia#55882.

- fixes JuliaLang/julia#55882

4 of 4 new or added lines in 1 file covered. (100.0%)

448 existing lines in 25 files now uncovered.

77170 of 88454 relevant lines covered (87.24%)

16041082.61 hits per line

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

57.95
/stdlib/Markdown/src/render/plain.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

UNCOV
3
plain(x) = sprint(plain, x)
×
4

5
function plain(io::IO, content::Vector)
418✔
6
    isempty(content) && return
418✔
7
    for md in content[1:end-1]
418✔
8
        plain(io, md)
251✔
9
        println(io)
251✔
10
    end
251✔
11
    plain(io, content[end])
418✔
12
end
13

14
plain(io::IO, md::MD) = plain(io, md.content)
382✔
15

16
function plain(io::IO, header::Header{l}) where l
91✔
17
    print(io, "#"^l*" ")
91✔
18
    plaininline(io, header.text)
91✔
19
    println(io)
91✔
20
end
21

22
function plain(io::IO, code::Code)
85✔
23
    # If the code includes a fenced block this will break parsing,
24
    # so it must be enclosed by a longer ````-sequence.
25
    n = mapreduce(m -> length(m.match), max, eachmatch(r"^`+"m, code.code); init=2) + 1
85✔
26
    println(io, "`" ^ n, code.language)
85✔
27
    println(io, code.code)
85✔
28
    println(io, "`" ^ n)
85✔
29
end
30

31
function plain(io::IO, p::Paragraph)
289✔
32
    plaininline(io, p.content)
289✔
33
    println(io)
289✔
34
end
35

36
function plain(io::IO, list::List)
12✔
37
    for (i, item) in enumerate(list.items)
12✔
38
        print(io, isordered(list) ? "$(i + list.ordered - 1). " : "  * ")
30✔
39
        lines = split(rstrip(sprint(plain, item)), "\n")
30✔
40
        for (n, line) in enumerate(lines)
60✔
41
            print(io, (n == 1 || isempty(line)) ? "" : "    ", line)
30✔
42
            n < length(lines) && println(io)
30✔
43
        end
30✔
44
        println(io)
30✔
45
    end
30✔
46
end
47

UNCOV
48
function plain(io::IO, q::BlockQuote)
×
UNCOV
49
    s = sprint(plain, q.content)
×
UNCOV
50
    for line in split(rstrip(s), "\n")
×
UNCOV
51
        println(io, isempty(line) ? ">" : "> ", line)
×
UNCOV
52
    end
×
UNCOV
53
    println(io)
×
54
end
55

UNCOV
56
function plain(io::IO, f::Footnote)
×
UNCOV
57
    print(io, "[^", f.id, "]:")
×
UNCOV
58
    s = sprint(plain, f.text)
×
UNCOV
59
    lines = split(rstrip(s), "\n")
×
60
    # Single line footnotes are printed on the same line as their label
61
    # rather than taking up an additional line.
UNCOV
62
    if length(lines) == 1
×
UNCOV
63
        println(io, " ", lines[1])
×
64
    else
UNCOV
65
        println(io)
×
UNCOV
66
        for line in lines
×
UNCOV
67
            println(io, isempty(line) ? "" : "    ", line)
×
UNCOV
68
        end
×
UNCOV
69
        println(io)
×
70
    end
71
end
72

73
function plain(io::IO, md::Admonition)
6✔
74
    s = sprint(plain, md.content)
6✔
75
    title = md.title == uppercasefirst(md.category) ? "" : " \"$(md.title)\""
6✔
76
    println(io, "!!! ", md.category, title)
6✔
77
    for line in split(rstrip(s), "\n")
6✔
78
        println(io, isempty(line) ? "" : "    ", line)
22✔
79
    end
22✔
80
    println(io)
6✔
81
end
82

UNCOV
83
function plain(io::IO, md::HorizontalRule)
×
UNCOV
84
    println(io, "-" ^ 3)
×
85
end
86

UNCOV
87
function plain(io::IO, l::LaTeX)
×
UNCOV
88
    println(io, '$', '$')
×
UNCOV
89
    println(io, l.formula)
×
UNCOV
90
    println(io, '$', '$')
×
91
end
92

93
function plain(io::IO, md)
×
94
    show(io,  MIME"text/plain"(), md)
×
95
    println(io)
×
96
end
97

98
# Inline elements
99

100
plaininline(x) = sprint(plaininline, x)
171✔
101

102
function plaininline(io::IO, md...)
78✔
103
    for el in md
78✔
104
        plaininline(io, el)
350✔
105
    end
340✔
106
end
107

108
plaininline(io::IO, md::Vector) = !isempty(md) && plaininline(io, md...)
396✔
109

UNCOV
110
plaininline(io::IO, f::Footnote) = print(io, "[^", f.id, "]")
×
111

112
plaininline(io::IO, link::Link) = plaininline(io, "[", link.text, "](", link.url, ")")
16✔
113

114
plaininline(io::IO, md::Image) = plaininline(io, "![", md.alt, "](", md.url, ")")
×
115

116
plaininline(io::IO, s::AbstractString) = print(io, s)
674✔
117

UNCOV
118
plaininline(io::IO, md::Bold) = plaininline(io, "**", md.text, "**")
×
119

UNCOV
120
plaininline(io::IO, md::Italic) = plaininline(io, "*", md.text, "*")
×
121

122
function plaininline(io::IO, md::Code)
139✔
123
    if occursin("`", md.code)
139✔
UNCOV
124
        n = maximum(length(m.match) for m in eachmatch(r"(`+)", md.code))
×
UNCOV
125
        s = "`"^((iseven(n) ? 1 : 2) + n)
×
UNCOV
126
        print(io, s, Base.startswith(md.code, "`") ? " " : "")
×
UNCOV
127
        print(io, md.code, endswith(md.code, "`") ? " " : "", s)
×
128
    else
129
        print(io, "`", md.code, "`")
139✔
130
    end
131
end
132

133
plaininline(io::IO, br::LineBreak) = println(io)
×
134

UNCOV
135
plaininline(io::IO, x) = show(io, MIME"text/plain"(), x)
×
136

137
# show
138

139
Base.show(io::IO, md::MD) = plain(io, md)
38✔
140
Base.show(io::IO, ::MIME"text/markdown", md::MD) = plain(io, md)
166✔
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