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

Return in function parameter initializer #73

Closed
Jack-Works opened this issue Aug 21, 2021 · 6 comments
Closed

Return in function parameter initializer #73

Jack-Works opened this issue Aug 21, 2021 · 6 comments

Comments

@Jack-Works
Copy link
Member

Is this allowed?

function x(y = do { return true }) {}
@bakkot
Copy link
Collaborator

bakkot commented Aug 21, 2021

See the readme:

return is allowed even within function parameter lists, as in function f(x = do { return null; }) {}.

@Jack-Works
Copy link
Member Author

Hmm, can we ban it? It seems like break or continue in the for loop heads. And it's also hard to implement as the method in #63

@pitaj
Copy link

pitaj commented Aug 22, 2021

The problem is that you'd need different rules just for when the do expression is used in default parameter position. Whereas the restrictions to break and continue apply to all do blocks.

@Jack-Works
Copy link
Member Author

The problem is that you'd need different rules just for when the do expression is used in default parameter position. Whereas the restrictions to break and continue apply to all do blocks.

Can you give an example? I didn't catch your meaning

@EdSaleh
Copy link

EdSaleh commented Sep 5, 2021

#74

@Jack-Works
Copy link
Member Author

implemented

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

No branches or pull requests

4 participants