JuliaServices / Match.jl

Advanced Pattern Matching for Julia
https://juliaservices.github.io/Match.jl/latest/
Other
240 stars 22 forks source link

Incorrect position on @warn #86

Open gafter opened 1 year ago

gafter commented 1 year ago

The following test is not correct:

    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.