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

use yp_statements_node_body_length a little bit more #1569

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/yarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ yp_statements_node_create(yp_parser_t *parser);
static void
yp_statements_node_body_append(yp_statements_node_t *node, yp_node_t *statement);

// Get the length of the given StatementsNode node's body.
static size_t
yp_statements_node_body_length(yp_statements_node_t *node);

// This function is here to allow us a place to extend in the future when we
// implement our own arena allocation.
static inline void *
Expand Down Expand Up @@ -2654,7 +2658,7 @@ yp_if_node_create(yp_parser_t *parser,
end = end_keyword->end;
} else if (consequent != NULL) {
end = consequent->location.end;
} else if ((statements != NULL) && (statements->body.size != 0)) {
} else if (yp_statements_node_body_length(statements) != 0) {
end = statements->base.location.end;
} else {
end = predicate->location.end;
Expand Down Expand Up @@ -4008,7 +4012,7 @@ yp_rescue_node_reference_set(yp_rescue_node_t *node, yp_node_t *reference) {
static void
yp_rescue_node_statements_set(yp_rescue_node_t *node, yp_statements_node_t *statements) {
node->statements = statements;
if ((statements != NULL) && (statements->body.size > 0)) {
if (yp_statements_node_body_length(statements) > 0) {
node->base.location.end = statements->base.location.end;
}
}
Expand Down