Skip to content

Commit 082691f

Browse files
Define exports to throw informative error in Julia DEV versions (#688)
1 parent 9ed5b27 commit 082691f

File tree

3 files changed

+51
-13
lines changed

3 files changed

+51
-13
lines changed

src/JET.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ const JET_DEV_MODE = Preferences.@load_preference("JET_DEV_MODE", false)
66

77
const JET_LOADABLE = JET_DEV_MODE || (get(VERSION.prerelease, 1, "") != "DEV")
88

9+
# exports
10+
# =======
11+
12+
export
13+
# jetanalyzer
14+
@report_call, report_call, @test_call, test_call,
15+
report_file, test_file, report_package, test_package, report_text, reportkey, test_text,
16+
watch_file,
17+
# optanalyzer
18+
@report_opt, report_opt, @test_opt, test_opt,
19+
# configurations
20+
LastFrameModule, AnyFrameModule
21+
922
# Pre-release Julia versions are not supported, and we don't expect JET to even
1023
# precompile in pre-release versions. So, instead of having JET fail to precompile, we
1124
# simply make JET an empty module so that failure is delayed until the first time JET is
@@ -21,6 +34,7 @@ else
2134
If you want to load JET on a nightly version, set the `JET_DEV_MODE` Preferences.jl
2235
configuration to `true` and reload it.
2336
"""
37+
include("JETEmpty.jl")
2438
end
2539

2640
end # module

src/JETBase.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
# exports
2-
# =======
3-
4-
export
5-
# jetanalyzer
6-
@report_call, report_call, @test_call, test_call,
7-
report_file, test_file, report_package, test_package, report_text, reportkey, test_text,
8-
watch_file,
9-
# optanalyzer
10-
@report_opt, report_opt, @test_opt, test_opt,
11-
# configurations
12-
LastFrameModule, AnyFrameModule
13-
141
let README = normpath(dirname(@__DIR__), "README.md")
152
s = read(README, String)
163
s = replace(s,

src/JETEmpty.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Empty stubs for the exported functions/macros of JET.jl, to provide a more informative
2+
# error message when JET.jl is used with a pre-release version of Julia.
3+
4+
const err_msg = strip("""
5+
JET.jl does not guarantee compatibility with pre-release versions of Julia and
6+
is not be loaded on this versions by default.
7+
Julia VERSION = $VERSION
8+
We recommend using a stable version of Julia in order to use JET.jl.
9+
Or to try JET with this pre-release Julia version use Preferences.jl to enable
10+
`JET_DEV_MODE`, and then reload JET. For example create a file named
11+
`LocalPreferences.toml` which contains the line:
12+
JET_DEV_MODE = true
13+
Note that JET.jl may not function properly with a pre-release versions of Julia
14+
even with `JET_DEV_MODE` enabled.
15+
""")
16+
17+
for exported_func in (
18+
:report_call, :test_call,
19+
:report_file, :test_file, :report_package, :test_package, :report_text, :reportkey, :test_text,
20+
:watch_file,
21+
# optanalyzer
22+
:report_opt, :test_opt,
23+
# configurations
24+
:LastFrameModule, :AnyFrameModule
25+
)
26+
@eval $exported_func(args...; kws...) = error($err_msg)
27+
end
28+
for exported_macro in (
29+
:report_call, :test_call,
30+
:report_opt, :test_opt
31+
)
32+
@eval begin
33+
macro $exported_macro(args...)
34+
error($err_msg)
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)