Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially easier way to escape functions #12

Open
kdpsingh opened this issue Feb 27, 2023 · 2 comments
Open

Potentially easier way to escape functions #12

kdpsingh opened this issue Feb 27, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kdpsingh
Copy link
Member

kdpsingh commented Feb 27, 2023

To make sure that user-provided functions are evaluated in the user's namespace (and not in the package namespace), Tidier currently escapes functions individually using MacroTools.postwalk.

While this generally works well, I believe there are corner cases where this fails, such as when a compound function is embedded within an anonymous function.

(x -> mean•skipmissing(x))

If this is rewritten as a non-compound function, then it works fine.

A potential solution is to escape the entire expression as it is interpolated into eg transform() or other functions, as opposed to escaping functions individually.

Will leave this issue here as something to explore as this will likely fix this edge-case bug.

@kdpsingh kdpsingh self-assigned this Feb 27, 2023
@kdpsingh kdpsingh added the bug Something isn't working label Feb 27, 2023
@kdpsingh
Copy link
Member Author

kdpsingh commented Mar 6, 2023

The reason the entire expression can't be escaped easily is that the anonymous functions are then created in the user's namespace, which is not what we want.

Leaving this issue open because I do want to fix the specific example here. Can probably fix it another way when parsing the expression.

@kdpsingh kdpsingh transferred this issue from TidierOrg/Tidier.jl Jul 31, 2023
@kdpsingh
Copy link
Member Author

kdpsingh commented Aug 2, 2023

Another related issue is that when multiple anonymous functions are used within an across(), they both get the suffix _function, which causes an error since they produce the same column name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant