summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-08-20 21:05:49 -0400
committergit <svn-admin@ruby-lang.org>2023-08-23 16:07:37 +0000
commitc837e1adfbcdf4d4df65f62d63c51c1111114b5f (patch)
tree986cefda06cdb10a3346a5c7cbf6232d6ec692ae
parent9c43ec621d72a7f98352f88b7fb27e0c599e1b7b (diff)
[ruby/yarp] Add LABEL lex state when lexing a keyword params
https://github.com/ruby/yarp/commit/422bcd0ebf
-rw-r--r--yarp/yarp.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index acf4f86a19..11041450f2 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -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;
@@ -8096,7 +8096,6 @@ parse_parameters(
bool looping = true;
yp_do_loop_stack_push(parser, false);
-
yp_parameters_order_t order = YP_PARAMETERS_ORDER_NONE;
do {
@@ -10965,6 +10964,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);