FluxML / IRTools.jl

Mike's Little Intermediate Representation
MIT License
111 stars 35 forks source link

Method redefinitions in tests break docs #113

Closed maleadt closed 4 months ago

maleadt commented 1 year ago

The tests redefine methods all the time (e.g. foo, foo1, relu) leading to method redefinition warnings on Julia 1.10:

WARNING: Method definition foo1(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/ir.jl:51 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/ir.jl:75.
WARNING: Method definition foo2(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/ir.jl:58 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/ir.jl:82.
WARNING: Method definition f(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/ir.jl:4 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/reflection.jl:4.
WARNING: Method definition roundtrip(Any...) in module Main at /home/tim/Julia/tmp/IRTools.jl/src/reflection/dynamo.jl:169 overwritten on the same line (check for duplicate calls to `include`).
WARNING: Method definition (::IRTools.Inner.Lambda{var"#s84"<:(Tuple{var"#s83", Vararg{Any}} where var"#s83"<:typeof(Main.roundtrip)), I, T})(Any...) in module Main at /home/tim/Julia/tmp/IRTools.jl/src/reflection/dynamo.jl:173 overwritten on the same line (check for duplicate calls to `include`).
WARNING: Method definition add(Any, Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/compiler.jl:14 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/compiler.jl:28.
WARNING: Method definition relu(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/analysis.jl:4 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/compiler.jl:31.
WARNING: Method definition relu(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/compiler.jl:31 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:4.
WARNING: Method definition pow(Any, Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/compiler.jl:134 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:14.
WARNING: Method definition relu(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:4 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:33.
WARNING: Method definition relu(Any) in module Main at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:33 overwritten at /home/tim/Julia/tmp/IRTools.jl/test/relooper.jl:41.

This breaks the doctests.

Fixing this probably involves putting those definitions in scoped blocks, or using @gensym and @eval when multiple definitions are involved (as otherwise the IR would be different).