Skip to content

Commit 1fc515c

Browse files
authored
Merge pull request #3796 from ruby/fix-up-call-target-invalid
Fix up call target node when invalid
2 parents 9de0c64 + 937313d commit 1fc515c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/prism.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,6 +3077,17 @@ pm_call_target_node_create(pm_parser_t *parser, pm_call_node_t *target) {
30773077
.message_loc = target->message_loc
30783078
};
30793079

3080+
/* It is possible to get here where we have parsed an invalid syntax tree
3081+
* where the call operator was not present. In that case we will have a
3082+
* problem because it is a required location. In this case we need to fill
3083+
* it in with a fake location so that the syntax tree remains valid. */
3084+
if (node->call_operator_loc.start == NULL) {
3085+
node->call_operator_loc = (pm_location_t) {
3086+
.start = target->base.location.start,
3087+
.end = target->base.location.start
3088+
};
3089+
}
3090+
30803091
// Here we're going to free the target, since it is no longer necessary.
30813092
// However, we don't want to call `pm_node_destroy` because we want to keep
30823093
// around all of its children since we just reused them.

0 commit comments

Comments
 (0)