Title: Crash with recursive default type parameter · Issue #21269 · python/mypy · GitHub
Open Graph Title: Crash with recursive default type parameter · Issue #21269 · python/mypy
X Title: Crash with recursive default type parameter · Issue #21269 · python/mypy
Description: Traceback 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.20...
Open Graph Description: Traceback 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://git...
X Description: Traceback 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://git...
Opengraph URL: https://github.com/python/mypy/issues/21269
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash with recursive default type parameter","articleBody":"\u003c!--\n Use this form only if mypy reports an \"INTERNAL ERROR\" and/or gives a traceback.\n Please include the traceback and all other messages below (use `mypy --show-traceback`).\n-->\n\n**Traceback**\n\n```python-traceback\nerror: INTERNAL ERROR -- Please try using mypy master on GitHub:\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\nPlease report a bug at https://github.com/python/mypy/issues\nversion: 1.20.1\nTraceback (most recent call last):\n File \"mypy/semanal.py\", line 7665, in accept\n File \"mypy/nodes.py\", line 1651, in accept\n File \"mypy/semanal.py\", line 1842, in visit_class_def\n File \"mypy/semanal.py\", line 1996, in analyze_class\n File \"mypy/semanal.py\", line 7311, in defer\nAssertionError: Must not defer during final iteration\nnote: use --pdb to drop into pdb\n```\n\n**To Reproduce**\n\n\n```python\nfrom typing import Protocol\n\n\nclass Trait[T: Pattern = Pattern](Protocol):\n def method(self, other: T) -> bool:\n \"\"\"Partial order on generality.\"\"\"\n raise NotImplementedError()\n\n\nclass Pattern1(Trait):\n def method(self, other: Pattern) -> bool:\n return False\n\nclass Pattern2(Trait):\n def method(self, other: Pattern) -> bool:\n return False\n\ntype Pattern = Pattern1 | Pattern2\n```\nThis simplified version does not crash:\n```python\nfrom typing import Protocol\n\n\nclass Trait[T](Protocol):\n def method(self, other: T) -> bool:\n \"\"\"Partial order on generality.\"\"\"\n raise NotImplementedError()\n\n\nclass Pattern1(Trait[\"Pattern\"]):\n def method(self, other: Pattern) -> bool:\n return False\n\nclass Pattern2(Trait[\"Pattern\"]):\n def method(self, other: Pattern) -> bool:\n return False\n\ntype Pattern = Pattern1 | Pattern2\n```\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: mypy 1.20.1 (compiled: yes)\n- Mypy command-line flags: --show-traceback\n- Mypy configuration options from `mypy.ini` (and other config files):\n```ini\n[mypy]\nwarn_unreachable = true\ndisallow_subclassing_any = true\ndisallow_incomplete_defs = true\ndisallow_untyped_defs = true\nwarn_unused_ignores = true\nwarn_unused_configs = true\nstrict_equality = true\nexclude_gitignore = true\nwarn_redundant_casts = true\npython_version = 3.14\n```\n- Python version used: 3.14\n- Operating system and version: Linux\n\n**Related Issues**\n- #17716\n- #21128 \n\nThis may be a duplicate but is a different way to reproduce the issue.","author":{"url":"https://github.com/George-Ogden","@type":"Person","name":"George-Ogden"},"datePublished":"2026-04-19T20:14:30Z","url":"https://github.com/python/mypy/issues/21269"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b3997a10-43b6-717c-4a47-f6f74ce65d93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1C2:1A3D7F:30360FC:3FB8048:6B00256E |
| html-safe-nonce | cfbafd091ab9853fe285917cbdabb62f251b8a5d9bf0b4fe25ecb0f2e18e54c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUMyOjFBM0Q3RjozMDM2MEZDOjNGQjgwNDg6NkIwMDI1NkUiLCJ2aXNpdG9yX2lkIjoiODM3NDk3NjQ2Mjc5MjQzNTA1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1eb54e6e6aa12bd3b65eb63f7e302448409ca4ca04d965ea05d157e2ce328788 |
| hovercard-subject-tag | issue:4291901363 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/21269/issue_layout |
| twitter:image | https://opengraph.githubassets.com/675e2d6fd3aa7ffd4c39a30be6e843e77092965aa6a6d099e43ba6f219f13aef/python/mypy/issues/21269 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/675e2d6fd3aa7ffd4c39a30be6e843e77092965aa6a6d099e43ba6f219f13aef/python/mypy/issues/21269 |
| og:image:alt | Traceback 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://git... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | George-Ogden |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width