Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Apr 9, 2021
2 parents 2d75fda + 5ed9dda commit f55b96e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/matchers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function matcher(term::Term)
function term_matcher(success, data, bindings)

!islist(data) && return nothing
!(istree(car(data))) && return nothing
!istree(car(data)) && return nothing

function loop(term, bindings′, matchers′) # Get it to compile faster
if !islist(matchers′)
Expand Down
2 changes: 2 additions & 0 deletions src/rule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ function makepattern(expr, keys)
else
:(term($(map(x->makepattern(x, keys), expr.args)...); type=Any))
end
elseif expr.head === :$
return esc(expr.args[1])
else
error("Unsupported Expr of type $(expr.head) found in pattern")
end
Expand Down
9 changes: 9 additions & 0 deletions test/rulesets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,12 @@ end
expr1 = foldr((x,y)->rand([*, /])(x,y), rand([a,b,c,d], 100))
SymbolicUtils.@timerewrite simplify(expr1)
end


@testset "interpolation" begin
f(y) = sin
@syms a

@test isnothing(@rule(f(1)(a) => 2)(sin(a)))
@test @rule($(f(1))(a) => 2)(sin(a)) == 2
end

0 comments on commit f55b96e

Please sign in to comment.