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

Do not allow BEGIN except the toplevel #1560

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

haldun
Copy link
Collaborator

@haldun haldun commented Sep 20, 2023

Closes #1540

src/yarp.c Outdated
@@ -12137,6 +12137,9 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
yp_statements_node_t *statements = parse_statements(parser, YP_CONTEXT_PREEXE);

expect1(parser, YP_TOKEN_BRACE_RIGHT, YP_ERR_BEGIN_UPCASE_TERM);
if ((parser->current_context->context != YP_CONTEXT_MAIN) && (parser->current_context->context != YP_CONTEXT_PREEXE)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract out a variable for the context so we're not accessing it twice?

@kddnewton
Copy link
Collaborator

This one needs a rebase as well

@kddnewton kddnewton merged commit c7231f1 into ruby:main Sep 22, 2023
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.

Ruby rejects def foo; BEGIN {}; end but YARP accepts it
2 participants