Skip to content

Commit

Permalink
adjust to JuliaLang/julia master (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Dec 15, 2022
1 parent 027bf46 commit 704d7b6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/analyzers/jetanalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -786,25 +786,20 @@ print_signature(::UndefVarErrorReport) = false
(::TypoPass)(::Type{UndefVarErrorReport}, analyzer::JETAnalyzer, sv::InferenceState, gr::GlobalRef) =
report_undef_global_var!(analyzer, sv, gr, #=sound=#false)
function report_undef_global_var!(analyzer::JETAnalyzer, sv::InferenceState, gr::GlobalRef, sound::Bool)
if !isdefined(gr.mod, gr.name)
report = false
if sound
report |= true
else
if is_corecompiler_undefglobal(gr)
elseif VERSION v"1.8.0-DEV.1465" && ccall(:jl_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing
# if this global var is explicitly type-declared, it will be likely get assigned somewhere
# TODO give this permission only to top-level analysis
else
report |= true
end
end
if report
add_new_report!(analyzer, sv.result, UndefVarErrorReport(sv, gr))
return true
end
isdefined(gr.mod, gr.name) && return false
sound && @goto report
is_corecompiler_undefglobal(gr) && return false
# if this global var is explicitly type-declared, it will be likely get assigned somewhere
# TODO give this permission only to top-level analysis
@static if VERSION v"1.10.0-DEV.145"
ccall(:jl_get_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing && return false
elseif VERSION v"1.8.0-DEV.1465"
ccall(:jl_binding_type, Any, (Any, Any), gr.mod, gr.name) !== nothing && return false
end
begin @label report
add_new_report!(analyzer, sv.result, UndefVarErrorReport(sv, gr))
return true
end
return false
end

# Returns `true` if this global reference is undefined inside `Core.Compiler`, but the
Expand Down Expand Up @@ -893,7 +888,11 @@ end
report_global_assignment!(analyzer, sv, mod, name, vtyp, #=sound=#false)
function report_global_assignment!(analyzer::JETAnalyzer,
sv::InferenceState, mod::Module, name::Symbol, @nospecialize(vtyp), sound::Bool)
btyp = ccall(:jl_binding_type, Any, (Any, Any), mod, name)
@static if VERSION v"1.10.0-DEV.145"
btyp = ccall(:jl_get_binding_type, Any, (Any, Any), mod, name)
else
btyp = ccall(:jl_binding_type, Any, (Any, Any), mod, name)
end
if btyp !== nothing
vtyp = widenconst(vtyp)
if !(sound ? vtyp btyp : hasintersect(vtyp, btyp))
Expand Down

0 comments on commit 704d7b6

Please sign in to comment.