mirror of
https://github.com/github/codeql.git
synced 2026-05-28 10:01:25 +02:00
Adds an `AnnAssignStmt` wrapper in `AstNodeImpl.qll` so that PEP 526 annotated assignments (`x: int = 1`, `x: int`) participate in the control flow graph. Evaluation order follows CPython: annotation, optional value, target binding. Without this, `x: int = 1` had no CFG node for `x` even though `Name.defines(v)` returns true for it on the AST side. SSA built on the new CFG would therefore miss every annotated-assignment write. Removes the corresponding MISSING: annotations from the CFG-binding gap test: - annassign.py — all four cases now green. - match_pattern.py — class-body annotated fields (`x: int`, `y: int`). - type_params.py — `item: T` inside class. Verified: all 24 ControlFlow/evaluation-order tests still pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 lines
354 B
Python
14 lines
354 B
Python
# Annotated assignment (PEP 526). Both with and without an initializer.
|
|
|
|
a: int = 1 # $ cfgdefines=a
|
|
b: str = "hi" # $ cfgdefines=b
|
|
|
|
# Annotation without value: the AST records `c` as defined,
|
|
# and the new CFG now visits it via the AnnAssignStmt wrapper.
|
|
c: int # $ cfgdefines=c
|
|
|
|
class K: # $ cfgdefines=K
|
|
field: int = 0 # $ cfgdefines=field
|
|
|
|
|