Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Closed
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
10 changes: 7 additions & 3 deletions languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ inherit .parent_module
body: (_) @body
) @func
(lambda
parameters: (_) @params
parameters: (_)? @params
body: (_) @body
)@func
] {
Expand All @@ -777,12 +777,16 @@ inherit .parent_module
node drop_scope

edge @func.call -> return_value
edge @body.before_scope -> @params.after_scope
if some @params {
edge @body.before_scope -> @params.after_scope
}
edge @body.before_scope -> drop_scope
edge drop_scope -> @func.bottom
attr (drop_scope) type = "drop_scopes"
attr (@func.call) pop_scoped_symbol = "()"
edge @params.before_scope -> JUMP_TO_SCOPE_NODE
if some @params {
edge @params.before_scope -> JUMP_TO_SCOPE_NODE
}
attr (return_value) is_exported
let @func.function_returns = return_value
}
Expand Down
9 changes: 9 additions & 0 deletions languages/tree-sitter-stack-graphs-python/test/lambdas.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
sorted([1, 2, 3], key=lambda x: x)
# ^ defined: 1

y = 42

foo = lambda: print(y)
# ^ defined: 4

bar = lambda daz: print(y, daz)
# ^ defined: 4
# ^ defined: 9