[ruby/prism] Do not warn for locals that start with _

https://github.com/ruby/prism/commit/8b8d66e55d
This commit is contained in:
Kevin Newton 2024-04-05 14:25:40 -04:00 committed by git
parent 37ba6927d1
commit a801889c58

View File

@ -1021,14 +1021,16 @@ pm_locals_order(PRISM_ATTRIBUTE_UNUSED pm_parser_t *parser, pm_locals_t *locals,
if (warn_unused && local->reads == 0) { if (warn_unused && local->reads == 0) {
pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name); pm_constant_t *constant = pm_constant_pool_id_to_constant(&parser->constant_pool, local->name);
PM_PARSER_WARN_FORMAT( if (constant->length >= 1 && *constant->start != '_') {
parser, PM_PARSER_WARN_FORMAT(
local->location.start, parser,
local->location.end, local->location.start,
PM_WARN_UNUSED_LOCAL_VARIABLE, local->location.end,
(int) constant->length, PM_WARN_UNUSED_LOCAL_VARIABLE,
(const char *) constant->start (int) constant->length,
); (const char *) constant->start
);
}
} }
} }
} }