From a946c1bd8e5e7e03e938fe5bb4df942affa95ec6 Mon Sep 17 00:00:00 2001 From: TSUYUSATO Kitsune Date: Sat, 5 Sep 2026 15:04:05 +0900 Subject: [PATCH] Report a void value in an and/or chain only once value_expr_check descended into the left operand of an and/or node, so a chain such as `x = (return) && (return) && a` reported the same void value once per operator instead of once. The left operand is already checked for a value when logop() builds the node, so stop at the node rather than descending. This matches the existing test_void_value_in_rhs expectation that the same warning is emitted just once, and mirrors the same change in ruby/prism#4221. --- parse.y | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index 78d3f4ab4c3baf..a5bbb047798222 100644 --- a/parse.y +++ b/parse.y @@ -13917,8 +13917,10 @@ value_expr_check(struct parser_params *p, NODE *node) case NODE_AND: case NODE_OR: - node = RNODE_AND(node)->nd_1st; - break; + /* The left operand was already checked for a value when logop() + * built this node, so stop here instead of re-reporting the same + * void value once per operator in a chain. */ + return NULL; case NODE_LASGN: case NODE_DASGN: