Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError: Cannot serialize ErasedType instance #9654

Closed
Kyuuhachi opened this issue Oct 27, 2020 · 2 comments · Fixed by #14087
Closed

NotImplementedError: Cannot serialize ErasedType instance #9654

Kyuuhachi opened this issue Oct 27, 2020 · 2 comments · Fixed by #14087
Labels

Comments

@Kyuuhachi
Copy link

Crash Report

I'm making a project that deals quite heavily with continuation-passing style, and I'm getting a crash.

Traceback

Traceback (most recent call last):
  File "~/.local/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "~/.local/lib/python3.8/site-packages/mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 90, in main
  File "mypy/build.py", line 180, in build
  File "mypy/build.py", line 254, in _build
  File "mypy/build.py", line 2630, in dispatch
  File "mypy/build.py", line 2953, in process_graph
  File "mypy/build.py", line 3070, in process_stale_scc
  File "mypy/build.py", line 2232, in write_cache
  File "mypy/build.py", line 1445, in write_cache
  File "mypy/nodes.py", line 303, in serialize
  File "mypy/nodes.py", line 3098, in serialize
  File "mypy/nodes.py", line 3037, in serialize
  File "mypy/nodes.py", line 883, in serialize
  File "mypy/types.py", line 814, in serialize
  File "mypy/types.py", line 145, in serialize
    "must be a (non-strict) subclass "
NotImplementedError: Cannot serialize ErasedType instance

To Reproduce

import typing as T

V = T.TypeVar("V")
V2 = T.TypeVar("V2")

def apply(val: V, func: T.Callable[[V], V2]) -> V2:
	return func(val)

xs = []
apply(0, lambda a: xs.append(a))

Your Environment

  • Mypy version used: mypy 0.790
  • Mypy command-line flags: None (just mypy error.py)
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: Python 3.8.6
  • Operating system and version: Linux 5.1.5-arch1-2-ARCH
@hauntsaninja
Copy link
Collaborator

Bisects to #8562

@hauntsaninja
Copy link
Collaborator

This still repros on master

ilevkivskyi added a commit that referenced this issue Nov 14, 2022
Fixes #9654

Seems to be quite straightforward. Erased types should never be stored
on variables, it is just a temporary thing for nested generic calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants