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

feat: always infer function call when args empty or have comma #3378

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gwhitney
Copy link
Collaborator

@gwhitney gwhitney commented Feb 5, 2025

This is a proposed PR to resolve #3358. It interprets EXPR() and EXPR(..., ...) as function calls regardless of what EXPR is, rather than syntax errors unless EXPR is a symbol or accessor. To enable this syntax to cover unary function calls as well, it allows a trailing comma in argument lists, meaning exp(3,) is now a legal synonym for exp(3). With these conventions, you can write (f(x) = x+1)(6,) to get 7.

I would totally be open to other syntaxes that would allow one to call a function that was the result of an expression (rather than a direct symbol or accessor), but I wanted a PR available so that you could try this one in practice.

Note that re-allowing expressions that return functions to be called makes a small handful of the security tests no longer simply syntax errors. However, all such tests still show these exploits ineffective, due to other security measures (that were likely already in place when the prior syntax for calling a function returned from an expression, (EXPR)(3), was eliminated in favor of implicit multiplication).

Looking forward to your thoughts.

@gwhitney
Copy link
Collaborator Author

gwhitney commented Feb 6, 2025

I recommend reading #3379 as well before reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant