if VERSION >= v"1.8"
@testset "warn for unreachable cases" begin
let line = (@__LINE__) + 4
@test_warn(
"$file:$line: Case 2: `Foo(1, 2) =>` is not reachable.",
# Test macros remove line number nodes, so we can only get the start of it
@eval @match2 Foo(1, 2) begin; Foo(_, _) => 1; Foo(1, 2) => 2; end
)
end
end
end
Specifically, the comment is incorrect. Test macros do no such thing. I have a similar test in AutoHashEqualsCached.jl that works with no such accommodation. I suspect the reason the line numbers were wrong in this test is that the pattern-matching implementation has a bug in tracking the line numbers. Fix the bug and the line numbers will be correct.
The following test is not correct:
Specifically, the comment is incorrect. Test macros do no such thing. I have a similar test in
AutoHashEqualsCached.jl
that works with no such accommodation. I suspect the reason the line numbers were wrong in this test is that the pattern-matching implementation has a bug in tracking the line numbers. Fix the bug and the line numbers will be correct.