summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/yarp/fuzzer_test.rb5
-rw-r--r--yarp/yarp.c8
2 files changed, 11 insertions, 2 deletions
diff --git a/test/yarp/fuzzer_test.rb b/test/yarp/fuzzer_test.rb
index d75d1422f0..4d7a0af8e7 100644
--- a/test/yarp/fuzzer_test.rb
+++ b/test/yarp/fuzzer_test.rb
@@ -28,5 +28,10 @@ module YARP
A
B
EOF
+ snippet "create a binary call node with arg before receiver", <<~EOF
+ <<-A.g/{/
+ A
+ /, ""\\
+ EOF
end
end
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 40d8d3c972..5b8fba9f62 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -161,6 +161,10 @@ debug_token(yp_token_t * token) {
#endif
+/* Macros for min/max. */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
/******************************************************************************/
/* Lex mode manipulations */
/******************************************************************************/
@@ -1240,8 +1244,8 @@ static yp_call_node_t *
yp_call_node_binary_create(yp_parser_t *parser, yp_node_t *receiver, yp_token_t *operator, yp_node_t *argument) {
yp_call_node_t *node = yp_call_node_create(parser);
- node->base.location.start = receiver->location.start;
- node->base.location.end = argument->location.end;
+ node->base.location.start = MIN(receiver->location.start, argument->location.start);
+ node->base.location.end = MAX(receiver->location.end, argument->location.end);
node->receiver = receiver;
node->message_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator);