Skip to content

Commit

Permalink
Merge pull request #91 from TidierOrg/bugfix-package-function-escaping
Browse files Browse the repository at this point in the history
Bug fix to allow `PackageName.function()` within macros to be used without escaping
  • Loading branch information
kdpsingh authored Feb 16, 2024
2 parents 98e9b09 + c09ee82 commit 45e5013
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# TidierData.jl updates

## v0.14.7 - 2024-02-16
- Bug fix to allow `PackageName.function()` within macros to be used without escaping

## v0.14.6 - 2024-02-03
- Bug fix to ensure that data type constructors are not escaped

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TidierData"
uuid = "fe2206b3-d496-4ee9-a338-6a095c4ece80"
authors = ["Karandeep Singh"]
version = "0.14.6"
version = "0.14.7"

[deps]
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"
Expand Down
29 changes: 16 additions & 13 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,12 @@ function parse_escape_function(rhs_expr::Union{Expr,Symbol})
if hasproperty(Base, variable) && !(typeof(getproperty(Base, variable)) <: Function)
# Remove the escaping if referring to a constant value like Base.pi and Base.Int64
return variable
elseif @capture(x, variable_Symbol) && hasproperty(Core, variable) && !(typeof(getproperty(Core, variable)) <: Function)
elseif hasproperty(Core, variable) && !(typeof(getproperty(Core, variable)) <: Function)
# Remove the escaping if referring to a data type like Core.Int64
return variable
elseif hasproperty(Statistics, variable) && !(typeof(getproperty(Statistics, variable)) <: Function)
# Because Statistics is re-exported
return variable
elseif variable in not_escaped[]
return variable
elseif contains(string(variable), r"[^\W0-9]\w*$") # valid variable name
Expand All @@ -366,17 +369,17 @@ function parse_escape_function(rhs_expr::Union{Expr,Symbol})
elseif @capture(x, fn_(args__))
if fn in not_escaped[]
return x
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
elseif fn isa Symbol && hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
return x
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
elseif fn isa Symbol && hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
return x
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
elseif fn isa Symbol && hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
return x
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
elseif fn isa Symbol && hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
return x
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
elseif fn isa Symbol && hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
return x
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
elseif fn isa Symbol && hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
return x
elseif contains(string(fn), r"[^\W0-9]\w*$") # valid variable name
return :($(esc(fn))($(args...)))
Expand All @@ -388,17 +391,17 @@ function parse_escape_function(rhs_expr::Union{Expr,Symbol})
# return x
if fn in not_escaped[]
return x
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
elseif fn isa Symbol && hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
return x
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
elseif fn isa Symbol && hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
return x
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
elseif fn isa Symbol && hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
return x
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
elseif fn isa Symbol && hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
return x
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
elseif fn isa Symbol && hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
return x
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
elseif fn isa Symbol && hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
return x
elseif contains(string(fn), r"[^\W0-9]\w*$") # valid variable name
return :($(esc(fn)).($(args...)))
Expand Down

2 comments on commit 45e5013

@kdpsingh
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
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/101012

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.14.7 -m "<description of version>" 45e5013246a40e21bed4665597b40a6793643597
git push origin v0.14.7

Please sign in to comment.