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

Add LABEL lex state when lexing a keyword params #1314

Merged
merged 1 commit into from
Aug 23, 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
9 changes: 7 additions & 2 deletions src/yarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ lex_state_ignored_p(yp_parser_t *parser) {

if (ignored) {
return YP_IGNORED_NEWLINE_ALL;
} else if (parser->lex_state == (YP_LEX_STATE_ARG | YP_LEX_STATE_LABELED)) {
} else if ((parser->lex_state & ~((unsigned int) YP_LEX_STATE_LABEL)) == (YP_LEX_STATE_ARG | YP_LEX_STATE_LABELED)) {
return YP_IGNORED_NEWLINE_PATTERN;
} else {
return YP_IGNORED_NEWLINE_NONE;
Expand Down Expand Up @@ -8082,7 +8082,6 @@ parse_parameters(
bool looping = true;

yp_do_loop_stack_push(parser, false);

yp_parameters_order_t order = YP_PARAMETERS_ORDER_NONE;

do {
Expand Down Expand Up @@ -10951,6 +10950,12 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
break;
}
case YP_CASE_PARAMETER: {
// If we're about to lex a label, we need to add the label
// state to make sure the next newline is ignored.
if (parser->current.type == YP_TOKEN_LABEL) {
lex_state_set(parser, parser->lex_state | YP_LEX_STATE_LABEL);
}

lparen = not_provided(parser);
rparen = not_provided(parser);
params = parse_parameters(parser, YP_BINDING_POWER_DEFINED, false, false, true);
Expand Down
Loading