Skip to content

#148 - Lambda arguments should be locals when the lambda is a local. #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: scip
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def my_cool_function_2(a: str):
x = ", world"
# ^ definition local 1
return (lambda y: a + x + y)("oh no")
# ^ definition local 2(y)
# ^ definition local 3
# ^ reference snapshot-util 0.1 `src.single_function`/my_cool_function_2().(a)
# ^ reference local 1
# ^ reference local 2(y)
# ^ reference local 3

def next_level():
# ^^^^^^^^^^ definition snapshot-util 0.1 `src.single_function`/next_level().
Expand Down
9 changes: 8 additions & 1 deletion packages/pyright-scip/src/treeVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,15 @@ export class TreeVisitor extends ParseTreeWalker {
log.debug('Paramerter with no name', node);
return ScipSymbol.local(this.counter.next());
}
// If the parent is a lambda, we can't generate a legal symbol
// by appending a descriptor; the parameter needs to be a local
// too.
const parentSymbol = this.getScipSymbol(node.parent!);
if (parentSymbol.isLocal()) {
return ScipSymbol.local(this.counter.next());
}

return Symbols.makeParameter(this.getScipSymbol(node.parent!), node.name.value);
return Symbols.makeParameter(parentSymbol, node.name.value);
}
case ParseNodeType.Class: {
return Symbols.makeType(this.getScipSymbol(node.parent!), (node as ClassNode).name.value);
Expand Down