Skip to content

Commit 62b5617

Browse files
committed
Warn, don't error, on precompile failures
1 parent 16853d3 commit 62b5617

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/precompile.jl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
macro warnpcfail(ex::Expr)
2+
modl = __module__
3+
file = __source__.file === nothing ? "?" : String(__source__.file)
4+
line = __source__.line
5+
quote
6+
$(esc(ex)) || @warn """precompile directive
7+
$($(Expr(:quote, ex)))
8+
failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line
9+
end
10+
end
11+
112
function pcarray(f::F, ::Type{A}, sz) where {F,A}
213
a = f(A(undef, sz))
314
fill!(a, zero(eltype(a)))
@@ -21,21 +32,21 @@ function _precompile_()
2132
szs = ((2,), (2, 2), (2, 2, 2), (2, 2, 2, 2))
2233

2334
for T in eltypes
24-
@assert precompile(clamp01, (T,))
25-
@assert precompile(clamp01nan, (T,))
26-
@assert precompile(scaleminmax, (T, T))
27-
@assert precompile(scalesigned, (T,))
28-
@assert precompile(scalesigned, (T,T,T))
35+
@warnpcfail precompile(clamp01, (T,))
36+
@warnpcfail precompile(clamp01nan, (T,))
37+
@warnpcfail precompile(scaleminmax, (T, T))
38+
@warnpcfail precompile(scalesigned, (T,))
39+
@warnpcfail precompile(scalesigned, (T,T,T))
2940
for C in pctypes
30-
@assert precompile(clamp01, (C{T},))
31-
@assert precompile(clamp01nan, (C{T},))
32-
@assert precompile(colorsigned, (C{T},C{T}))
41+
@warnpcfail precompile(clamp01, (C{T},))
42+
@warnpcfail precompile(clamp01nan, (C{T},))
43+
@warnpcfail precompile(colorsigned, (C{T},C{T}))
3344
end
3445
end
3546
for C in cctypes
36-
@assert precompile(clamp01, (C,))
37-
@assert precompile(clamp01nan, (C,))
38-
@assert precompile(colorsigned, (C,C))
47+
@warnpcfail precompile(clamp01, (C,))
48+
@warnpcfail precompile(clamp01nan, (C,))
49+
@warnpcfail precompile(colorsigned, (C,C))
3950
end
4051
# For the arrays, it's better to make them and exercise them so we get the getindex/setindex!
4152
# methods precompiled too.

0 commit comments

Comments
 (0)