Skip to content

Commit 98e9b09

Browse files
authored
Merge pull request #85 from TidierOrg/no-escape-types
2 parents f4569d4 + 4d8ae87 commit 98e9b09

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# TidierData.jl updates
22

3+
## v0.14.6 - 2024-02-03
4+
- Bug fix to ensure that data type constructors are not escaped
5+
36
## v0.14.5 - 2024-01-23
47
- Adds `@relocate()`
58

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TidierData"
22
uuid = "fe2206b3-d496-4ee9-a338-6a095c4ece80"
33
authors = ["Karandeep Singh"]
4-
version = "0.14.5"
4+
version = "0.14.6"
55

66
[deps]
77
Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc"

src/parsing.jl

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ function parse_escape_function(rhs_expr::Union{Expr,Symbol})
351351
# If it's already escaped, make sure it needs to remain escaped
352352
if @capture(x, esc(variable_Symbol))
353353
if hasproperty(Base, variable) && !(typeof(getproperty(Base, variable)) <: Function)
354-
# Remove the escaping if referring to a constant value like Base.pi
354+
# Remove the escaping if referring to a constant value like Base.pi and Base.Int64
355355
return variable
356356
elseif @capture(x, variable_Symbol) && hasproperty(Core, variable) && !(typeof(getproperty(Core, variable)) <: Function)
357357
# Remove the escaping if referring to a data type like Core.Int64
@@ -364,21 +364,41 @@ function parse_escape_function(rhs_expr::Union{Expr,Symbol})
364364
return variable
365365
end
366366
elseif @capture(x, fn_(args__))
367-
if hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
367+
if fn in not_escaped[]
368+
return x
369+
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
368370
return x
369371
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
370372
return x
371373
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
372374
return x
373-
elseif fn in not_escaped[]
375+
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
376+
return x
377+
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
378+
return x
379+
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
374380
return x
375381
elseif contains(string(fn), r"[^\W0-9]\w*$") # valid variable name
376382
return :($(esc(fn))($(args...)))
377383
else
378384
return x
379385
end
380386
elseif @capture(x, fn_.(args__))
381-
if fn in [:esc :in : : :Ref :Set :Cols :(:) : :across :desc :mean :std :var :median :first :last :minimum :maximum :sum :length :skipmissing :quantile :passmissing :startswith :contains :endswith]
387+
# if fn in [:esc :in :∈ :∉ :Ref :Set :Cols :(:) :∘ :across :desc :mean :std :var :median :first :last :minimum :maximum :sum :length :skipmissing :quantile :passmissing :startswith :contains :endswith]
388+
# return x
389+
if fn in not_escaped[]
390+
return x
391+
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Function
392+
return x
393+
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Function
394+
return x
395+
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Function
396+
return x
397+
elseif hasproperty(Base, fn) && typeof(getproperty(Base, fn)) <: Type
398+
return x
399+
elseif hasproperty(Core, fn) && typeof(getproperty(Core, fn)) <: Type
400+
return x
401+
elseif hasproperty(Statistics, fn) && typeof(getproperty(Statistics, fn)) <: Type
382402
return x
383403
elseif contains(string(fn), r"[^\W0-9]\w*$") # valid variable name
384404
return :($(esc(fn)).($(args...)))
@@ -439,9 +459,11 @@ function parse_interpolation(var_expr::Union{Expr,Symbol,Number,String};
439459
elseif @capture(x, variable_Symbol)
440460
if variable in not_escaped[]
441461
return variable
442-
elseif hasproperty(Base, variable) && !(typeof(getproperty(Base, variable)) <: Function)
462+
elseif hasproperty(Base, variable) && !(typeof(getproperty(Base, variable)) <: Function) && !(typeof(getproperty(Base, variable)) <: Type)
443463
return esc(variable)
444-
elseif @capture(x, variable_Symbol) && hasproperty(Core, variable) && !(typeof(getproperty(Core, variable)) <: Function)
464+
elseif hasproperty(Core, variable) && !(typeof(getproperty(Core, variable)) <: Function) && !(typeof(getproperty(Core, variable)) <: Type)
465+
return esc(variable)
466+
elseif hasproperty(Statistics, variable) && !(typeof(getproperty(Statistics, variable)) <: Function) && !(typeof(getproperty(Statistics, variable)) <: Type)
445467
return esc(variable)
446468
else
447469
return variable

0 commit comments

Comments
 (0)