Skip to content

Commit 0ad3056

Browse files
committed
Fix hash pattern location when missing nodes
1 parent 8c12a6b commit 0ad3056

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/prism.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,8 +4096,8 @@ pm_hash_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *eleme
40964096

40974097
if (elements->size > 0) {
40984098
if (rest) {
4099-
start = elements->nodes[0]->location.start;
4100-
end = rest->location.end;
4099+
start = MIN(rest->location.start, elements->nodes[0]->location.start);
4100+
end = MAX(rest->location.end, elements->nodes[elements->size - 1]->location.end);
41014101
} else {
41024102
start = elements->nodes[0]->location.start;
41034103
end = elements->nodes[elements->size - 1]->location.end;
@@ -4117,11 +4117,7 @@ pm_hash_pattern_node_node_list_create(pm_parser_t *parser, pm_node_list_t *eleme
41174117
.closing_loc = { 0 }
41184118
};
41194119

4120-
pm_node_t *element;
4121-
PM_NODE_LIST_FOREACH(elements, index, element) {
4122-
pm_node_list_append(&node->elements, element);
4123-
}
4124-
4120+
pm_node_list_concat(&node->elements, elements);
41254121
return node;
41264122
}
41274123

0 commit comments

Comments
 (0)