Skip to content

Commit 2878dd0

Browse files
committed
add a basic similarterm for matchable types
1 parent 555f552 commit 2878dd0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/code.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,9 @@ function cse_block!(assignments, counter, names, name, state, x)
740740
if isterm(x)
741741
return term(operation(x), args...)
742742
else
743-
return similarterm(x, operation(x), args, symtype(x),
744-
metadata=metadata(x))
743+
return similarterm(x, operation(x),
744+
args, symtype(x),
745+
metadata=metadata(x))
745746
end
746747
else
747748
return x

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ macro matchable(expr)
223223
SymbolicUtils.operation(::$name) = $name
224224
SymbolicUtils.arguments(x::$name) = getfield.((x,), ($(QuoteNode.(fields)...),))
225225
Base.length(x::$name) = $(length(fields) + 1)
226+
SymbolicUtils.similarterm(x::$name, f, args, type; kw...) = f(args...)
226227
end |> esc
227228
end
228229

0 commit comments

Comments
 (0)