Skip to content

Unable to reason over ADT #257

@adrianleh

Description

@adrianleh

Hi,

I'm using the ale/3.0 branch, and I am trying to reason over an ADT implemented with abstract types (code below)

using Metatheory
using Metatheory.TermInterface

# Define the Dim data type
abstract type Dim end


struct Lit <: Dim
    value::Int64
end


# Define constructors for Dim
struct Plus{T<:Dim, U<:Dim} <: Dim
    dim1::T
    dim2::U
end

@rule Plus(Lit(0), ~dim1) --> ~dim1;

It fails with the following error:

ERROR: LoadError: MethodError: no method matching match_term_op(::Metatheory.Patterns.PatExpr, ::Symbol, ::Type{Main.dcac.Plus})
The function `match_term_op` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  match_term_op(::Metatheory.Patterns.AbstractPat, ::Any, ::Metatheory.Patterns.PatVar)
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:215
  match_term_op(::Any, ::Any, ::Union{Expr, Symbol})
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:212
  match_term_op(::Any, ::Any, ::Union{DataType, Function})
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:207

Stacktrace:
 [1] match_term_expr(pattern::Metatheory.Patterns.PatExpr, coordinate::Vector{Int64}, segments_so_far::Vector{Symbol})
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:224
 [2] match_compile!(pattern::Metatheory.Patterns.PatExpr, state::Metatheory.MatchCompilerState, coordinate::Vector{Int64}, parent_segments::Vector{Symbol})
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:144
 [3] match_compile(p::Metatheory.Patterns.PatExpr, pvars::Vector{Symbol})
   @ Metatheory ~/.julia/packages/Metatheory/HvfSQ/src/match_compiler.jl:34
 [4] var"@rule"(__source__::LineNumberNode, __module__::Module, args::Vararg{Any})
   @ Metatheory.Syntax ~/.julia/packages/Metatheory/HvfSQ/src/Syntax.jl:428
 [5] include(fname::String)
   @ Main ./sysimg.jl:38
 [6] top-level scope
   @ REPL[3]:1

Is there a workaround for this, or is this a metatheory.jl issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions