Skip to content

Commit

Permalink
Merge pull request #9 from JuliaSymbolics/s/similarterm-signature
Browse files Browse the repository at this point in the history
fix method chosen when exprhead is not used
  • Loading branch information
0x0f0f0f authored Oct 4, 2021
2 parents f3a0dfe + b9d56f7 commit 2afe1e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TermInterface"
uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
authors = ["Shashi Gowda <[email protected]>", "Alessandro Cheli <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[compat]
julia = "1"
Expand Down
11 changes: 8 additions & 3 deletions src/TermInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,21 @@ 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
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...)
Expand Down

2 comments on commit 2afe1e3

@0x0f0f0f
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:
Fixed bug in exprhead and similarterm.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/46072

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" 2afe1e37e1a1633d2138d69f2d831c1c75351b62
git push origin v0.2.1

Please sign in to comment.