Skip to content

Commit 2fdeb5c

Browse files
authored
fix cache of GeneratorErrorReport (#242)
1 parent 6591201 commit 2fdeb5c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/JET.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,8 @@ function (::SoundBasicPass)(::Type{GeneratorErrorReport}, analyzer::AbstractAnal
966966
ccall(:jl_code_for_staged, Any, (Any,), mi)
967967
catch err
968968
# if user code throws error, wrap and report it
969-
add_new_report!(GeneratorErrorReport(analyzer, mi, err), analyzer)
969+
report = add_new_report!(GeneratorErrorReport(analyzer, mi, err), analyzer)
970+
push!(get_to_be_updated(analyzer), report)
970971
end
971972
end
972973
end

test/test_abstractinterpretation.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -911,28 +911,34 @@ end
911911
end
912912
throw("invalid argument")
913913
end
914+
915+
bar(args...) = foo(args...)
914916
end
915917

916-
# successful code generation, valid code
917-
let
918+
let # successful code generation, valid code
918919
analyzer, = report_call(m.foo, (Int,))
919920
@test isempty(get_reports(analyzer))
920921
end
921922

922-
# successful code generation, invalid code
923-
let
923+
let # successful code generation, invalid code
924924
analyzer, = report_call(m.foo, (Float64,))
925925
@test length(get_reports(analyzer)) == 1
926926
r = first(get_reports(analyzer))
927927
@test isa(r, GlobalUndefVarErrorReport)
928928
@test r.name === :undefvar
929929
end
930930

931-
# unsuccessful code generation
932-
let
931+
let # unsuccessful code generation
933932
analyzer, = report_call(m.foo, (String,))
934933
@test length(get_reports(analyzer)) == 1
935934
r = first(get_reports(analyzer))
936935
@test isa(r, GeneratorErrorReport) && r.err == "invalid argument"
937936
end
937+
938+
let # should work if cached
939+
analyzer, = report_call(m.bar, (String,))
940+
@test length(get_reports(analyzer)) == 1
941+
r = first(get_reports(analyzer))
942+
@test isa(r, GeneratorErrorReport) && r.err == "invalid argument"
943+
end
938944
end

0 commit comments

Comments
 (0)