mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
Should fix #1833, #2137, and #2187. Internally, comprehensions are (at present) elaborated into local functions and iterators as described in [PEP-289](https://www.python.org/dev/peps/pep-0289/). That is, something like: ``` g = (x**2 for x in range(10)) ``` becomes something akin to ``` def __gen(exp): for x in exp: yield x**2 g = __gen(iter(range(10))) ``` In the context of the top-level of a class, this means `__gen` looks as if it is a method of the class, and in particular `exp` looks like it's the `self` argument of this method, which leads the points-to analysis to think that `exp` is an instance of the surrounding class itself. The fix in this case is pretty simple: we look for occurrences of `exp` (in fact called `.0` internally -- carefully chosen to _not_ be a valid Python identifier) and explicitly exclude this parameter from being classified as a `self` parameter.