Skip to content

Better error message for calling @match on non-record struct instance #179

Open
@jariji

Description

@jariji

Give a better error message, recommending @as_record B.

julia> struct B
           a
           b
           c
       end


julia> @match B(1,2,3) begin
           B(a,b,c) => (a,b,c)
       end
ERROR: LoadError: PatternCompilationError(:(#= REPL[5]:2 =#), MethodError(MLStyle.MatchImpl.pattern_uncall, (B, MLStyle.MatchImpl.ModuleBoundedEx2tf(Main), Any[], Any[], Any[:a, :b, :c]), 0x0000000000007b2f))
in expression starting at REPL[5]:1

caused by: MethodError: no method matching pattern_uncall(::Type{B}, ::MLStyle.MatchImpl.ModuleBoundedEx2tf, ::Vector{Any}, ::Vector{Any}, ::SubArray{Any, 1, Vector{Any}, Tuple{UnitRange{Int64}}, true})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions