Commit b6f1421
Python: model
Add a 4th disjunct to `SsaImplInput::variableWrite` in the shared-SSA
adapter that mirrors legacy ESSA's `ImportStarRefinement`: every
variable whose scope is the import-star's scope, OR which is used in
the import-star's scope, gets an uncertain write at the `import *`
position.
Uncertain writes do not kill prior definitions; shared SSA's
`SsaUncertainWrite` joins the new value with the immediately-preceding
definition via `uncertainWriteDefinitionInput`. This is the equivalent
of legacy ESSA's two-input refinement.
Cannot depend on `ImportStar` / `ImportResolution` (those modules
import `SsaImpl`), so the predicate uses the structural heuristic on
`Cfg::ImportStarNode` directly.
This closes the two remaining failing dataflow library-tests:
- `import-star/global` — `module_export` chains via `from X import *`
re-exports now resolve: the importing module has an SSA def of every
re-exported name, so `lastUseVar` finds the read at the use site.
- `typetracking_imports/highlight_problem` — a direct `from .foo import
foo` immediately followed by `from .other import *` is now correctly
marked as dead at the direct import.
Two scope-entry-def noise rows in `highlight_problem.expected` are also
dropped — legacy ESSA needed them as refinement inputs, but shared SSA
handles uncertain writes without an explicit prior def. They were
always tagged `no use to normal exit` (dead).
Dataflow library-tests: 62/64 → 64/64 passing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>from X import * as uncertain SSA writes1 parent 1a2be46 commit b6f1421
2 files changed
Lines changed: 41 additions & 20 deletions
File tree
- python/ql
- lib/semmle/python/dataflow/new/internal
- test/library-tests/dataflow/typetracking_imports
Lines changed: 34 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 51 | | |
60 | 52 | | |
61 | 53 | | |
| |||
113 | 105 | | |
114 | 106 | | |
115 | 107 | | |
116 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
117 | 111 | | |
118 | 112 | | |
119 | 113 | | |
| |||
223 | 217 | | |
224 | 218 | | |
225 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
226 | 245 | | |
227 | 246 | | |
228 | 247 | | |
| |||
400 | 419 | | |
401 | 420 | | |
402 | 421 | | |
403 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
404 | 425 | | |
405 | 426 | | |
406 | 427 | | |
407 | 428 | | |
408 | 429 | | |
409 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
410 | 433 | | |
411 | 434 | | |
412 | 435 | | |
| |||
Lines changed: 7 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments