Skip to content

Regression: crash when serializing alias to generic class method #8072

@JukkaL

Description

@JukkaL

Type checking this program causes a crash during serialization of x:

from typing import TypeVar

T = TypeVar('T')

class C:
    @classmethod
    def f(cls, x: T) -> T: ...

x = C.f

Here's the traceback:

Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/jukka/src/mypy/mypy/__main__.py", line 12, in <module>
    main(None, sys.stdout, sys.stderr)
  File "/Users/jukka/src/mypy/mypy/main.py", line 89, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/Users/jukka/src/mypy/mypy/build.py", line 167, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "/Users/jukka/src/mypy/mypy/build.py", line 235, in _build
    graph = dispatch(sources, manager, stdout)
  File "/Users/jukka/src/mypy/mypy/build.py", line 2620, in dispatch
    process_graph(graph, manager)
  File "/Users/jukka/src/mypy/mypy/build.py", line 2929, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/Users/jukka/src/mypy/mypy/build.py", line 3047, in process_stale_scc
    graph[id].write_cache()
  File "/Users/jukka/src/mypy/mypy/build.py", line 2244, in write_cache
    self.manager)
  File "/Users/jukka/src/mypy/mypy/build.py", line 1410, in write_cache
    data = tree.serialize()
  File "/Users/jukka/src/mypy/mypy/nodes.py", line 302, in serialize
    'names': self.names.serialize(self._fullname),
  File "/Users/jukka/src/mypy/mypy/nodes.py", line 3083, in serialize
    data[key] = value.serialize(fullname, key)
  File "/Users/jukka/src/mypy/mypy/nodes.py", line 3021, in serialize
    data['node'] = self.node.serialize()
  File "/Users/jukka/src/mypy/mypy/nodes.py", line 882, in serialize
    'type': None if self.type is None else self.type.serialize(),
  File "/Users/jukka/src/mypy/mypy/types.py", line 1218, in serialize
    'arg_types': [t.serialize() for t in self.arg_types],
  File "/Users/jukka/src/mypy/mypy/types.py", line 1218, in <listcomp>
    'arg_types': [t.serialize() for t in self.arg_types],
  File "/Users/jukka/src/mypy/mypy/types.py", line 885, in serialize
    assert not self.id.is_meta_var()
AssertionError

This is a regression introduced in #8021.

cc @ilevkivskyi

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy