Skip to content

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

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

Draft
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.

@josdejong
Copy link
Owner

Thanks for working out this PR. I totally understand the need to be able to invoke a function returned by a function, we have to come up with some solution for that. I'm a bit in doubt about this solution, since it doesn't work for unary functions except when adding a "magic" trailing comma.

This discussion now overlaps with #3379 (comment), shall we continue the discussion there?

@gwhitney
Copy link
Collaborator Author

This discussion now overlaps with #3379 (comment), shall we continue the discussion there?

Yes of course, that was really the intention; this PR is mainly a proof of concept for one possible notation. (I mean, it is complete and workable if that notation is chosen, but clearly there are alternatives to choose from.)

@gwhitney gwhitney marked this pull request as draft April 23, 2025 16:03
@gwhitney
Copy link
Collaborator Author

(Marked as draft to recognize this contingency on design decisions.)

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.

2 participants