From a801889c580663dde984afa2c27811a8d2438597 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Fri, 5 Apr 2024 14:25:40 -0400 Subject: [PATCH] [ruby/prism] Do not warn for locals that start with _ https://github.com/ruby/prism/commit/8b8d66e55d --- prism/prism.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/prism/prism.c b/prism/prism.c index 52a1dca482..3ac298dcb0 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -1021,14 +1021,16 @@ pm_locals_order(PRISM_ATTRIBUTE_UNUSED pm_parser_t *parser, pm_locals_t *locals, if (warn_unused && local->reads == 0) { pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name); - PM_PARSER_WARN_FORMAT( - parser, - local->location.start, - local->location.end, - PM_WARN_UNUSED_LOCAL_VARIABLE, - (int) constant->length, - (const char *) constant->start - ); + if (constant->length >= 1 && *constant->start != '_') { + PM_PARSER_WARN_FORMAT( + parser, + local->location.start, + local->location.end, + PM_WARN_UNUSED_LOCAL_VARIABLE, + (int) constant->length, + (const char *) constant->start + ); + } } } }