Skip to content

Commit 090580b

Browse files
committed
refactor(python): scope the nested-def counter to the Python branch
cppcheck 2.20 variableScope on defs_before; same behaviour. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent f6b5059 commit 090580b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎internal/cbm/extract_defs.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12261,16 +12261,17 @@ static void walk_defs(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec,
1226112261
}
1226212262
if (cbm_kind_in_set(node, spec->function_node_types)) {
1226312263
if (!is_template_class_node(node, ctx->language)) {
12264-
int defs_before = ctx->result->defs.count;
12265-
extract_func_def(ctx, node, spec);
1226612264
if (ctx->language == CBM_LANG_PYTHON) {
12265+
int defs_before = ctx->result->defs.count;
12266+
extract_func_def(ctx, node, spec);
1226712267
if (ctx->result->defs.count > defs_before) {
1226812268
py_push_def_body(&s, node,
1226912269
ctx->result->defs.items[ctx->result->defs.count - SKIP_ONE]
1227012270
.qualified_name);
1227112271
}
1227212272
continue;
1227312273
}
12274+
extract_func_def(ctx, node, spec);
1227412275
// Most languages stop here. JS/TS (and Wolfram) descend into the
1227512276
// function body so NESTED named definitions are also captured —
1227612277
// e.g. arrow methods of an object literal returned from a factory

0 commit comments

Comments
 (0)