[ruby/prism] Fix not
receiver
`not foo` should be `!foo` `not()` should be `!nil` Fixes [Bug #21027] https://github.com/ruby/prism/commit/871ed4b462
This commit is contained in:
parent
9c962ea792
commit
117d6e145a
@ -1045,10 +1045,20 @@ module Prism
|
||||
bounds(node.location)
|
||||
on_unary(node.name, receiver)
|
||||
when :!
|
||||
receiver = visit(node.receiver)
|
||||
if node.message == "not"
|
||||
receiver =
|
||||
if !node.receiver.is_a?(ParenthesesNode) || !node.receiver.body.nil?
|
||||
visit(node.receiver)
|
||||
end
|
||||
|
||||
bounds(node.location)
|
||||
on_unary(node.message == "not" ? :not : :!, receiver)
|
||||
bounds(node.location)
|
||||
on_unary(:not, receiver)
|
||||
else
|
||||
receiver = visit(node.receiver)
|
||||
|
||||
bounds(node.location)
|
||||
on_unary(:!, receiver)
|
||||
end
|
||||
when *BINARY_OPERATORS
|
||||
receiver = visit(node.receiver)
|
||||
value = visit(node.arguments.arguments.first)
|
||||
|
@ -19719,11 +19719,12 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
accept1(parser, PM_TOKEN_NEWLINE);
|
||||
|
||||
if (accept1(parser, PM_TOKEN_PARENTHESIS_LEFT)) {
|
||||
arguments.opening_loc = PM_LOCATION_TOKEN_VALUE(&parser->previous);
|
||||
pm_token_t lparen = parser->previous;
|
||||
|
||||
if (accept1(parser, PM_TOKEN_PARENTHESIS_RIGHT)) {
|
||||
arguments.closing_loc = PM_LOCATION_TOKEN_VALUE(&parser->previous);
|
||||
receiver = (pm_node_t *) pm_parentheses_node_create(parser, &lparen, NULL, &parser->previous);
|
||||
} else {
|
||||
arguments.opening_loc = PM_LOCATION_TOKEN_VALUE(&lparen);
|
||||
receiver = parse_expression(parser, PM_BINDING_POWER_COMPOSITION, true, false, PM_ERR_NOT_EXPRESSION, (uint16_t) (depth + 1));
|
||||
|
||||
if (!parser->recovering) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user