2 ms·
I wonder if there is some principled way of making Julia-style method dispatch statically checkable?
by skybrian 5y ago
I wonder if there is some principled way of making Julia-style method dispatch statically checkable?
- mindB 5y agoJET.jl does a surprisingly good job of statically checking julia type errors as well as other classes of errors using only type-level code analysis. https://github.com/aviatesk/JET.jl https://github.com/aviatesk/JET.jl It does catch method ambiguities like those shown in this blog post: julia> using JET julia> f(x, y::Int) = x + y f (generic function with 2 methods) julia> f(x::Int, y) = x - y f (generic function with 2 methods) julia> g(x, y) = f(x, y) g (generic function with 1 method) julia> @test_call g(1, 2) JET-test failed at REPL[13]:1 Expression: #= REPL[13]:1 =# JET.@test_call g(1, 2) ═════ 1 possible error found ═════ ┌ @ REPL[12]:1 Main.f(x, y) │ no matching method found for call signature (Tuple{typeof(f), Int64, Int64}): Main.f(x::Int64, y::Int64) └────────────── ERROR: There was an error during testing