|
1 | 1 | module Analyzer |
2 | 2 |
|
3 | 3 | export LSAnalyzer, inference_error_report_severity, inference_error_report_stack, reset_report_target_modules! |
4 | | -export BoundsErrorReport, FieldErrorReport, MethodErrorReport, UndefVarErrorReport |
| 4 | +export BoundsErrorReport, FieldErrorReport, UndefVarErrorReport |
5 | 5 |
|
6 | 6 | using Core.IR |
7 | 7 | using JET.JETInterface |
@@ -244,47 +244,6 @@ end # @static if VERSION ≥ v"1.12.2" |
244 | 244 | # Analysis injections |
245 | 245 | # =================== |
246 | 246 |
|
247 | | -# function is_from_kwcall(analyzer, sv) |
248 | | -# report_target_modules = @something analyzer.report_target_modules return false |
249 | | -# checkbounds(Bool, sv.callstack, sv.parentid) || return false |
250 | | -# sv = sv.callstack[sv.parentid] |
251 | | -# checkbounds(Bool, sv.callstack, sv.parentid) || return false |
252 | | -# sv = sv.callstack[sv.parentid] |
253 | | -# mi = CC.frame_instance(sv) |
254 | | -# def = mi.def |
255 | | -# def isa Method || return false |
256 | | -# sig = Base.unwrap_unionall(def.sig) |
257 | | -# sig isa DataType || return false |
258 | | -# length(sig.parameters) >= 1 || return false |
259 | | -# sig.parameters[1] === typeof(Core.kwcall) || return false |
260 | | -# checkbounds(Bool, sv.callstack, sv.parentid) || return false |
261 | | -# sv = sv.callstack[sv.parentid] |
262 | | -# return CC.frame_module(sv) ∈ report_target_modules |
263 | | -# end |
264 | | - |
265 | | -function CC.abstract_call_gf_by_type( |
266 | | - analyzer::LSAnalyzer, @nospecialize(func), arginfo::CC.ArgInfo, si::CC.StmtInfo, |
267 | | - @nospecialize(atype), sv::CC.InferenceState, max_methods::Int |
268 | | - ) |
269 | | - ret = @invoke CC.abstract_call_gf_by_type(analyzer::ToplevelAbstractAnalyzer, |
270 | | - func::Any, arginfo::CC.ArgInfo, si::CC.StmtInfo, atype::Any, sv::CC.InferenceState, max_methods::Int) |
271 | | - if !should_analyze(analyzer, sv) |
272 | | - return ret |
273 | | - end |
274 | | - atype′ = Ref{Any}(atype) |
275 | | - function after_abstract_call_gf_by_type(analyzer′::LSAnalyzer, sv′::CC.InferenceState) |
276 | | - ret′ = ret[] |
277 | | - report_method_error!(analyzer′, sv′, ret′, arginfo, atype′[]) |
278 | | - return true |
279 | | - end |
280 | | - if isready(ret) |
281 | | - after_abstract_call_gf_by_type(analyzer, sv) |
282 | | - else |
283 | | - push!(sv.tasks, after_abstract_call_gf_by_type) |
284 | | - end |
285 | | - return ret |
286 | | -end |
287 | | - |
288 | 247 | # TODO Better to factor out and share it with `JET.JETAnalyzer` |
289 | 248 | function CC.abstract_eval_globalref( |
290 | 249 | analyzer::LSAnalyzer, g::GlobalRef, saw_latestworld::Bool, sv::CC.InferenceState; |
@@ -520,84 +479,6 @@ function report_fieldaccess!( |
520 | 479 | return true |
521 | 480 | end |
522 | 481 |
|
523 | | -# MethodErrorReport |
524 | | -# ----------------- |
525 | | - |
526 | | -@jetreport struct MethodErrorReport <: LSErrorReport |
527 | | - @nospecialize t # ::Union{Type, Vector{Type}} |
528 | | - union_split::Int |
529 | | -end |
530 | | -function JETInterface.print_report_message(io::IO, report::MethodErrorReport) |
531 | | - print(io, "no matching method found ") |
532 | | - if report.union_split == 0 |
533 | | - print_callsig(io, report.t) |
534 | | - else |
535 | | - ts = report.t::Vector{Any} |
536 | | - nts = length(ts) |
537 | | - for i = 1:nts |
538 | | - print_callsig(io, ts[i]) |
539 | | - i == nts || print(io, ", ") |
540 | | - end |
541 | | - print(io, " (", nts, '/', report.union_split, " union split)") |
542 | | - end |
543 | | -end |
544 | | -function print_callsig(io, @nospecialize(t)) |
545 | | - print(io, '`') |
546 | | - Base.show_tuple_as_call(io, Symbol(""), t) |
547 | | - print(io, '`') |
548 | | -end |
549 | | -inference_error_report_stack_impl(r::MethodErrorReport) = length(r.vst):-1:1 |
550 | | -inference_error_report_severity_impl(::MethodErrorReport) = DiagnosticSeverity.Warning |
551 | | - |
552 | | -function report_method_error!( |
553 | | - analyzer::LSAnalyzer, sv::CC.InferenceState, call::CC.CallMeta, |
554 | | - arginfo::CC.ArgInfo, @nospecialize(atype) |
555 | | - ) |
556 | | - info = call.info |
557 | | - if isa(info, CC.ConstCallInfo) |
558 | | - info = info.call |
559 | | - end |
560 | | - if isa(info, CC.MethodMatchInfo) |
561 | | - report_method_error!(analyzer, sv, info, atype) |
562 | | - elseif isa(info, CC.UnionSplitInfo) |
563 | | - report_method_error_for_union_split!(analyzer, sv, info, arginfo) |
564 | | - end |
565 | | -end |
566 | | - |
567 | | -function report_method_error!( |
568 | | - analyzer::LSAnalyzer, sv::CC.InferenceState, info::CC.MethodMatchInfo, |
569 | | - @nospecialize(atype) |
570 | | - ) |
571 | | - if CC.isempty(info.results) |
572 | | - report = MethodErrorReport(sv, atype, 0) |
573 | | - add_new_report!(analyzer, sv.result, report) |
574 | | - end |
575 | | -end |
576 | | - |
577 | | -function report_method_error_for_union_split!( |
578 | | - analyzer::LSAnalyzer, sv::CC.InferenceState, info::CC.UnionSplitInfo, |
579 | | - arginfo::CC.ArgInfo |
580 | | - ) |
581 | | - # check each match for union-split signature |
582 | | - split_argtypes = empty_matches = nothing |
583 | | - for (i, matchinfo) in enumerate(info.split) |
584 | | - if CC.isempty(matchinfo.results) |
585 | | - if isnothing(split_argtypes) |
586 | | - split_argtypes = CC.switchtupleunion(CC.typeinf_lattice(analyzer), arginfo.argtypes) |
587 | | - end |
588 | | - argtypes′ = split_argtypes[i]::Vector{Any} |
589 | | - if empty_matches === nothing |
590 | | - empty_matches = (Any[], length(info.split)) |
591 | | - end |
592 | | - sig_n = CC.argtypes_to_type(argtypes′) |
593 | | - push!(empty_matches[1], sig_n) |
594 | | - end |
595 | | - end |
596 | | - if empty_matches !== nothing |
597 | | - add_new_report!(analyzer, sv.result, MethodErrorReport(sv, empty_matches...)) |
598 | | - end |
599 | | -end |
600 | | - |
601 | 482 | # Constructor |
602 | 483 | # =========== |
603 | 484 |
|
|
0 commit comments