mirror of
https://github.com/github/codeql.git
synced 2026-05-30 19:11:23 +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>
24 lines
698 B
Python
24 lines
698 B
Python
# Match-statement pattern bindings.
|
|
|
|
def f(subject): # $ cfgdefines=f
|
|
match subject:
|
|
case x: # $ MISSING: cfgdefines=x
|
|
pass
|
|
case [a, b]: # $ MISSING: cfgdefines=a MISSING: cfgdefines=b
|
|
pass
|
|
case {"k": v}: # $ MISSING: cfgdefines=v
|
|
pass
|
|
case Point(p, q): # $ MISSING: cfgdefines=p MISSING: cfgdefines=q
|
|
pass
|
|
case [_, *rest]: # $ MISSING: cfgdefines=rest
|
|
pass
|
|
case (1 | 2) as n: # $ MISSING: cfgdefines=n
|
|
pass
|
|
|
|
|
|
class Point: # $ cfgdefines=Point
|
|
__match_args__ = ("x", "y") # $ cfgdefines=__match_args__
|
|
x: int # $ cfgdefines=x
|
|
y: int # $ cfgdefines=y
|
|
|