From 80edc2c59908d05fc15fd2b9929938c8badbbdd0 Mon Sep 17 00:00:00 2001 From: Bastiaan Marinus van de Weerd Date: Wed, 2 Apr 2025 11:13:03 -0300 Subject: [PATCH] Fix nested assignments in Python. --- .../src/stack-graphs.tsg | 1 + .../test/assignments.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 languages/tree-sitter-stack-graphs-python/test/assignments.py diff --git a/languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg b/languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg index 5fb407ae8..86f68d77c 100644 --- a/languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg +++ b/languages/tree-sitter-stack-graphs-python/src/stack-graphs.tsg @@ -158,6 +158,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n (generator_expression) (ellipsis) (list_splat) + (assignment) ; expression list (expression_list) diff --git a/languages/tree-sitter-stack-graphs-python/test/assignments.py b/languages/tree-sitter-stack-graphs-python/test/assignments.py new file mode 100644 index 000000000..83ed01b70 --- /dev/null +++ b/languages/tree-sitter-stack-graphs-python/test/assignments.py @@ -0,0 +1,11 @@ +x = 42 + +print(x) +# ^ defined: 1 + +y = z = 1337 + +print(x, y, z) +# ^ defined: 1 +# ^ defined: 6 +# ^ defined: 6