[ruby/prism] Fix unary not location

https://github.com/ruby/prism/commit/861689f6d1
This commit is contained in:
Kevin Newton 2024-02-12 11:27:42 -05:00 committed by git
parent 16b39072a5
commit c3886c12dc
2 changed files with 6 additions and 7 deletions

View File

@ -2891,7 +2891,7 @@ static pm_def_node_t *
pm_def_node_create( pm_def_node_create(
pm_parser_t *parser, pm_parser_t *parser,
pm_constant_id_t name, pm_constant_id_t name,
const pm_location_t *name_loc, const pm_token_t *name_loc,
pm_node_t *receiver, pm_node_t *receiver,
pm_parameters_node_t *parameters, pm_parameters_node_t *parameters,
pm_node_t *body, pm_node_t *body,
@ -2922,7 +2922,7 @@ pm_def_node_create(
.location = { .start = def_keyword->start, .end = end }, .location = { .start = def_keyword->start, .end = end },
}, },
.name = name, .name = name,
.name_loc = *name_loc, .name_loc = PM_LOCATION_TOKEN_VALUE(name_loc),
.receiver = receiver, .receiver = receiver,
.parameters = parameters, .parameters = parameters,
.body = body, .body = body,
@ -15627,13 +15627,12 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
* methods to override the unary operators, we should ignore * methods to override the unary operators, we should ignore
* the @ in the same way we do for symbols. * the @ in the same way we do for symbols.
*/ */
pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &name); pm_constant_id_t name_id = pm_parser_constant_id_location(parser, name.start, parse_operator_symbol_name(&name));
pm_location_t name_loc = { .start = name.start, .end = parse_operator_symbol_name(&name) };
return (pm_node_t *) pm_def_node_create( return (pm_node_t *) pm_def_node_create(
parser, parser,
name_id, name_id,
&name_loc, &name,
receiver, receiver,
params, params,
statements, statements,

View File

@ -4,8 +4,8 @@
@ StatementsNode (location: (1,0)-(1,17)) @ StatementsNode (location: (1,0)-(1,17))
└── body: (length: 1) └── body: (length: 1)
└── @ DefNode (location: (1,0)-(1,17)) └── @ DefNode (location: (1,0)-(1,17))
├── name: :"!@" ├── name: :!
├── name_loc: (1,4)-(1,5) = "!" ├── name_loc: (1,4)-(1,6) = "!@"
├── receiver: ∅ ├── receiver: ∅
├── parameters: ∅ ├── parameters: ∅
├── body: ├── body: