Infinite loop at the end of file makes pytype output name-error with global lambda referring to a global variable #1842
Open
Description
Consider the following file
b = 1
lam = lambda: b
This passes pytype without problems.
However, adding an extra while loop at the end:
b = 1
lam = lambda: b
while True:
pass
I now get an error:
jik@hostname:~/projects/test$ pytype --version
2024.10.11
jik@hostname:~/projects/test$ pytype simple.py
Computing dependencies
Analyzing 1 sources with 0 local dependencies
ninja: Entering directory `.pytype'
[1/1] check simple
FAILED: /home/jik/projects/test/.pytype/pyi/simple.pyi
/usr/bin/python3 -m pytype.main --imports_info /home/jik/projects/test/.pytype/imports/simple.imports --module-name simple --platform linux -V 3.10 -o /home/jik/projects/test/.pytype/pyi/simple.pyi --analyze-annotated --nofail --quick /home/jik/projects/test/simple.py
/home/jik/projects/test/simple.py:2:1: error: in <lambda>: Name 'b' is not defined [name-error]
lam = lambda: b~~~~~~~~~~~~~~
lam = lambda: b
For more details, see https://google.github.io/pytype/errors.html#name-error
ninja: build stopped: subcommand failed.
Leaving directory '.pytype'
It passes again if I replace the pass
by break
or if I change the while True
to while False
/if True
/if False
, so I guess there's something particular with the infinite loop that confuses pytype.
Metadata
Assignees
Labels
No labels