Skip to content

Commit

Permalink
[ruby/prism] Unary not name location
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Feb 12, 2024
1 parent 739eec0 commit 78deba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions prism/prism.c
Expand Up @@ -2890,7 +2890,8 @@ pm_def_node_receiver_check(pm_parser_t *parser, const pm_node_t *node) {
static pm_def_node_t *
pm_def_node_create(
pm_parser_t *parser,
const pm_token_t *name,
pm_constant_id_t name,
const pm_location_t *name_loc,
pm_node_t *receiver,
pm_parameters_node_t *parameters,
pm_node_t *body,
Expand Down Expand Up @@ -2920,8 +2921,8 @@ pm_def_node_create(
.type = PM_DEF_NODE,
.location = { .start = def_keyword->start, .end = end },
},
.name = pm_parser_constant_id_token(parser, name),
.name_loc = PM_LOCATION_TOKEN_VALUE(name),
.name = name,
.name_loc = *name_loc,
.receiver = receiver,
.parameters = parameters,
.body = body,
Expand Down Expand Up @@ -15626,11 +15627,13 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
* methods to override the unary operators, we should ignore
* the @ in the same way we do for symbols.
*/
name.end = parse_operator_symbol_name(&name);
pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &name);
pm_location_t name_loc = { .start = name.start, .end = parse_operator_symbol_name(&name) };

return (pm_node_t *) pm_def_node_create(
parser,
&name,
name_id,
&name_loc,
receiver,
params,
statements,
Expand Down
2 changes: 1 addition & 1 deletion test/prism/snapshots/seattlerb/defn_unary_not.txt
Expand Up @@ -4,7 +4,7 @@
@ StatementsNode (location: (1,0)-(1,17))
└── body: (length: 1)
└── @ DefNode (location: (1,0)-(1,17))
├── name: :!
├── name: :"!@"
├── name_loc: (1,4)-(1,5) = "!"
├── receiver: ∅
├── parameters: ∅
Expand Down

0 comments on commit 78deba1

Please sign in to comment.