summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prism/config.yml2
-rw-r--r--prism/prism.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/prism/config.yml b/prism/config.yml
index 14afabb6e4..badefec5f1 100644
--- a/prism/config.yml
+++ b/prism/config.yml
@@ -4085,6 +4085,8 @@ nodes:
- on error: BackReferenceReadNode # => begin; rescue => $&; end
- on error: NumberedReferenceReadNode # => begin; rescue => $1; end
- on error: MissingNode # begin; rescue =>; end
+ - name: then_keyword_loc
+ type: location?
- name: statements
type: node?
kind: StatementsNode
diff --git a/prism/prism.c b/prism/prism.c
index ed907bd5ac..10e4747a6e 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -6684,6 +6684,7 @@ pm_rescue_node_create(pm_parser_t *parser, const pm_token_t *keyword) {
},
.keyword_loc = PM_LOCATION_TOKEN_VALUE(keyword),
.operator_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
+ .then_keyword_loc = PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE,
.reference = NULL,
.statements = NULL,
.subsequent = NULL,
@@ -15078,8 +15079,8 @@ parse_rescues(pm_parser_t *parser, size_t opening_newline_index, const pm_token_
case PM_TOKEN_NEWLINE:
case PM_TOKEN_SEMICOLON:
case PM_TOKEN_KEYWORD_THEN:
- // Here we have a terminator for the rescue keyword, in which case we're
- // going to just continue on.
+ // Here we have a terminator for the rescue keyword, in which
+ // case we're going to just continue on.
break;
default: {
if (token_begins_expression_p(parser->current.type) || match1(parser, PM_TOKEN_USTAR)) {
@@ -15111,9 +15112,12 @@ parse_rescues(pm_parser_t *parser, size_t opening_newline_index, const pm_token_
}
if (accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON)) {
- accept1(parser, PM_TOKEN_KEYWORD_THEN);
+ if (accept1(parser, PM_TOKEN_KEYWORD_THEN)) {
+ rescue->then_keyword_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(&parser->previous);
+ }
} else {
expect1(parser, PM_TOKEN_KEYWORD_THEN, PM_ERR_RESCUE_TERM);
+ rescue->then_keyword_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(&parser->previous);
}
if (!match3(parser, PM_TOKEN_KEYWORD_ELSE, PM_TOKEN_KEYWORD_ENSURE, PM_TOKEN_KEYWORD_END)) {