diff --git a/Project.toml b/Project.toml index 918638e..6745536 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TermInterface" uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c" authors = ["Shashi Gowda ", "Alessandro Cheli "] -version = "0.2.0" +version = "0.2.1" [compat] julia = "1" diff --git a/src/TermInterface.jl b/src/TermInterface.jl index a1111f8..6f63e9c 100644 --- a/src/TermInterface.jl +++ b/src/TermInterface.jl @@ -110,7 +110,7 @@ end """ - similarterm(x, head, args, symtype=nothing; metadata=nothing, exprhead=exprhead(x)) + similarterm(x, head, args, symtype=nothing; metadata=nothing, exprhead=:call) Returns a term that is in the same closure of types as `typeof(x)`, with `head` as the head and `args` as the arguments, `type` as the symtype @@ -118,8 +118,13 @@ and `metadata` as the metadata. By default this will execute `head(args...)`. `x` parameter can also be a `Type`. The `exprhead` keyword argument is useful when manipulating `Expr`s. """ -similarterm(x, head, args, symtype=nothing; metadata=nothing, exprhead=exprhead(x)) = - similarterm(typeof(x), head, args, symtype; metadata=metadata, exprhead=exprhead) +function similarterm(x, head, args, symtype=nothing; metadata=nothing, exprhead=nothing) + if exprhead === nothing + similarterm(typeof(x), head, args, symtype; metadata=metadata) + else + similarterm(typeof(x), head, args, symtype; metadata=metadata, exprhead=exprhead) + end +end function similarterm(x::Type{T}, head, args, symtype=nothing; metadata=nothing, exprhead=:call) where T !istree(T) ? head : head(args...)