aviatesk / JET.jl

An experimental code analyzer for Julia. No need for additional type annotations.
https://aviatesk.github.io/JET.jl/dev/
MIT License
708 stars 29 forks source link

`AnyFrameModule` error #644

Closed MilesCranmer closed 5 days ago

MilesCranmer commented 5 days ago

When running with

JET.test_package(
    DynamicExpressions;
    target_defined_modules=true,
    ignored_modules=(
        JET.AnyFrameModule(
            DynamicExpressions.NonDifferentiableDeclarationsModule
        ),
    ),
)

in an attempt to ignore #642, I get the issue:

Error During Test at /Users/mcranmer/.julia/packages/JET/6kXRQ/src/JET.jl:1053
  Test threw exception
  Expression: (JET.report_package)(DynamicExpressions; toplevel_logger = nothing, target_defined_modules = true, ignored_modules = (AnyFrameModule(DynamicExpressions.NonDifferentiableDeclarationsModule),))
  `JET.match_module(::NonDifferentiableDeclarationsModule, ::InferenceErrorReport)` is not implemented
  Stacktrace:
    [1] error(s::LazyString)
      @ Base ./error.jl:35
    [2] match_module(x::String, report::JET.InferenceErrorReport)
      @ JET ~/.julia/packages/JET/6kXRQ/src/JET.jl:533
    [3] (::JET.var"#93#97"{JET.MethodErrorReport})(m::String)
      @ JET ~/.julia/packages/JET/6kXRQ/src/JET.jl:544
...

This seems like an issue because I would have assumed that AnyFrameModule would have been automatically implemented? So I am not sure why it requires the custom match_module definition.


Note also that DynamicExpressions.NonDifferentiableDeclarationsModule is a submodule. But, it should still get caught:

julia> DE.NonDifferentiableDeclarationsModule |> typeof
Module

so I'm confused...

MilesCranmer commented 5 days ago

Actually it looks like any package might not work?

julia> JET.test_package(
           DynamicExpressions;
           ignored_modules=[DynamicExpressions]
       )
Error During Test at /Users/mcranmer/.julia/packages/JET/6kXRQ/src/JET.jl:1053
  Test threw exception
  Expression: (JET.report_package)(DynamicExpressions; toplevel_logger = nothing, ignored_modules = Module[DynamicExpressions])
  `JET.match_module(::NonDifferentiableDeclarationsModule, ::InferenceErrorReport)` is not implemented
  Stacktrace:
    [1] error(s::LazyString)
      @ Base ./error.jl:35
    [2] match_module(x::String, report::JET.InferenceErrorReport)
      @ JET ~/.julia/packages/JET/6kXRQ/src/JET.jl:533
    [3] (::JET.var"#93#97"{JET.MethodErrorReport})(m::String)
      @ JET ~/.julia/packages/JET/6kXRQ/src/JET.jl:544
    [4] _any
      @ ./reduce.jl:1220 [inlined]
    [5] any
      @ ./reducedim.jl:1020 [inlined]
    [6] #92
      @ ~/.julia/packages/JET/6kXRQ/src/JET.jl:544 [inlined]
    [7] filter(f::JET.var"#92#96"{JET.ReportConfig{Nothing, Vector{String}}}, a::Vector{JET.InferenceErrorReport})
      @ Base ./array.jl:2675
    [8] configured_reports

is something converting it to a string?

Also related (maybe repeat of) #570

MilesCranmer commented 5 days ago

Argh. Nevermind, sorry. It's because I had it in the .JET.toml file and it wasn't converting the specified ignored_modules to Module type.

aviatesk commented 5 days ago

As explained in the note on the JET configuration documentation, please note that configurations specified in .JET.toml are overridden by those specified as keyword arguments. What complicates the issue is likely the fact that ignored_modules used in the patterns like above does not work properly (i.e. report_package(A::Module; ignored_modules=(A::Module,)). This is because [test|report]_package virtualizes the module context of the package being analyzed. I plan to fix this issue soon along with #628 and other related issues.