python / python/mypy

visit_lambda_expr list index out of range

Open
#17,215 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

crash
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Traceback

Traceback (most recent call last):                                                                                                                                                                                                                   
  File "/Users/tilak/.pyenv/versions/venv-3.10/bin/mypy", line 8, in <module>                                                                                                                                                                        
    sys.exit(console_entry())                                                                                                                                                                                                                        
  File "/Users/tilak/.pyenv/versions/venv-3.10/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry                                                                                                                             
    main()                                                                                                                                                                                                                                           
  File "mypy/main.py", line 100, in main                                                                                                                                                                                                             
  File "mypy/main.py", line 182, in run_build                                                                                                                                                                                                        
  File "mypy/build.py", line 192, in build                                                                                                                                                                                                           
  File "mypy/build.py", line 266, in _build                                                                                                                                                                                                          
  File "mypy/build.py", line 2942, in dispatch                                                                                                                                                                                                       
  File "mypy/build.py", line 3333, in process_graph                                                                                                                                                                                                  
  File "mypy/build.py", line 3414, in process_fresh_modules                                                                                                                                                                                          
  File "mypy/build.py", line 2110, in fix_cross_refs                                                                                                                                                                                                 
  File "mypy/fixup.py", line 52, in fixup_module                                                                                                                                                                                                     
  File "mypy/fixup.py", line 158, in visit_symbol_table                                                                                                                                                                                              
  File "mypy/nodes.py", line 1037, in accept                                                                                                                                                                                                         
  File "mypy/fixup.py", line 211, in visit_var                                                                                                                                                                                                       
  File "mypy/types.py", line 1435, in accept                                                                                                                                                                                                         
  File "mypy/fixup.py", line 230, in visit_instance                                                                                                                                                                                                  
  File "mypy/fixup.py", line 371, in lookup_fully_qualified_typeinfo                                                                                                                                                                                 
AssertionError: Should never get here in normal mode, got TypeAlias:threading.local instead of TypeInfo 
<path redacted>.py:-1: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.9.0
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5742, in accept
  File "mypy/nodes.py", line 2213, in accept
  File "mypy/checkexpr.py", line 5217, in visit_lambda_expr
  File "mypy/nodes.py", line 2206, in expr
IndexError: list index out of range
<redacted>.py:-1: : note: use --pdb to drop into pdb

To Reproduce

I'm unable to share the source code, but the errors above occur alternately when commenting out a type definition,
objects: list[CustomType] = [] vs. objects: list[CustomType] = [].

Your Environment

  • Mypy version used: 1.9.0
  • Mypy command-line flags: --install-types --non-interactive --show-traceback
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10.9
  • Operating system and version: MacOS Sonoma 14.4.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the reported traceback locations in mypy/checkexpr.py, mypy/nodes.py, mypy/fixup.py, and mypy/types.py, then try the supplied mypy 1.9.0 command if a reproducer becomes available. Done would require a minimal reproducible case and a regression test showing that the lambda expression no longer raises either internal error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.