You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Functions nested in different methods of a class all get the symbol Class#name(). #231
The two different functions share one symbol, which is also the symbol a real method Graph.visit would have. The index ends up with two definitions of one symbol that have different parameters, and each call references both.
Expected:Graph#order().visit(). and Graph#check().visit().. That is what scip-python already emits for functions nested in module-level functions: def first(): def inner() gives first().inner(). for both the definition and the call.
Cause:makeScipSymbol (the Function case) and getFunctionSymbol call ParseTreeUtils.getEnclosingClass(node) with stopAtFunction = false, so a function nested in a method finds the method's class and skips the method.
Possible fix (packages/pyright-scip/src/treeVisitor.ts):
case ParseNodeType.Function: {
- let cls = ParseTreeUtils.getEnclosingClass(node, false);+ let cls = ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true);
- const enclosingClass = ParseTreeUtils.getEnclosingClass(decl.node);+ if (ParseTreeUtils.getEnclosingFunction(decl.node)) {+ // A nested function: use the same symbol as its definition.+ return this.getScipSymbol(decl.node);+ }++ const enclosingClass = ParseTreeUtils.getEnclosingClass(decl.node, /* stopAtFunction */ true);
With this change, the example gives Graph#order().visit(). and Graph#check().visit(). for each definition and its call, and the existing snapshot outputs are unchanged. Related, but a different case: #160. I can open a PR with a snapshot test.
Activity
linear commentedon Oct 21, 2026
OSS-24227