From bf47f66691cf8bb9110489f27b07cb858139a83d Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Thu, 28 Aug 2025 10:37:21 +0200 Subject: [PATCH] Python: Add jump-to-def tests for unpacking assignments --- .../analysis/jump_to_defn/Definitions.expected | 3 +++ python/ql/test/query-tests/analysis/jump_to_defn/test.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/python/ql/test/query-tests/analysis/jump_to_defn/Definitions.expected b/python/ql/test/query-tests/analysis/jump_to_defn/Definitions.expected index 1162bce43fa..5c7c31ea4b2 100644 --- a/python/ql/test/query-tests/analysis/jump_to_defn/Definitions.expected +++ b/python/ql/test/query-tests/analysis/jump_to_defn/Definitions.expected @@ -26,3 +26,6 @@ | test.py:44:8:44:14 | ImportExpr | package/__init__.py:0:0:0:0 | Definition package/__init__.py:0 | Definition | | test.py:45:1:45:1 | p | test.py:44:8:44:14 | Definition test.py:44 | Definition | | test.py:45:3:45:3 | Attribute | package/__init__.py:2:18:2:18 | Definition package/__init__.py:2 | Definition | +| test.py:48:32:48:38 | dirname | test.py:47:9:47:15 | Definition test.py:47 | Definition | +| test.py:50:34:50:38 | lines | test.py:47:18:47:22 | Definition test.py:47 | Definition | +| test.py:53:12:53:12 | x | test.py:49:9:49:12 | Definition test.py:49 | Definition | diff --git a/python/ql/test/query-tests/analysis/jump_to_defn/test.py b/python/ql/test/query-tests/analysis/jump_to_defn/test.py index 0abfeb32c40..b9be08a4867 100644 --- a/python/ql/test/query-tests/analysis/jump_to_defn/test.py +++ b/python/ql/test/query-tests/analysis/jump_to_defn/test.py @@ -43,3 +43,11 @@ thing.bar from package import x import package as p p.x + +def foo(dirname, lines): + head, tail = os.path.split(dirname) + x = head # `head` is missing jump-to-def target + for start, line in enumerate(lines): + line = line.strip() # `line` is missing jump-to-def target + break + return x \ No newline at end of file