Title: Annotated assignment in a `match` block does not generate `SETUP_ANNOTATIONS` · Issue #105164 · python/cpython · GitHub
Open Graph Title: Annotated assignment in a `match` block does not generate `SETUP_ANNOTATIONS` · Issue #105164 · python/cpython
X Title: Annotated assignment in a `match` block does not generate `SETUP_ANNOTATIONS` · Issue #105164 · python/cpython
Description: Bug report Compiling the following code: match 0: case 0: x: int = 1 generates 1 0 LOAD_CONST 0 (0) 2 2 LOAD_CONST 0 (0) 4 COMPARE_OP 2 (==) 6 POP_JUMP_IF_FALSE 12 (to 24) 3 8 LOAD_CONST 1 (1) 10 STORE_NAME 0 (x) 12 LOAD_NAME 1 (int) 14 ...
Open Graph Description: Bug report Compiling the following code: match 0: case 0: x: int = 1 generates 1 0 LOAD_CONST 0 (0) 2 2 LOAD_CONST 0 (0) 4 COMPARE_OP 2 (==) 6 POP_JUMP_IF_FALSE 12 (to 24) 3 8 LOAD_CONST 1 (1) 10 S...
X Description: Bug report Compiling the following code: match 0: case 0: x: int = 1 generates 1 0 LOAD_CONST 0 (0) 2 2 LOAD_CONST 0 (0) 4 COMPARE_OP 2 (==) 6 POP_JUMP_IF_FALSE 12 (to 24) 3 8 LOAD_CONST 1 (1) 10 S...
Opengraph URL: https://github.com/python/cpython/issues/105164
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Annotated assignment in a `match` block does not generate `SETUP_ANNOTATIONS`","articleBody":"# Bug report\r\n\r\nCompiling the following code:\r\n\r\n```\r\nmatch 0:\r\n case 0:\r\n x: int = 1\r\n```\r\n\r\ngenerates\r\n\r\n```\r\n 1 0 LOAD_CONST 0 (0)\r\n\r\n 2 2 LOAD_CONST 0 (0)\r\n 4 COMPARE_OP 2 (==)\r\n 6 POP_JUMP_IF_FALSE 12 (to 24)\r\n\r\n 3 8 LOAD_CONST 1 (1)\r\n 10 STORE_NAME 0 (x)\r\n 12 LOAD_NAME 1 (int)\r\n 14 LOAD_NAME 2 (__annotations__)\r\n 16 LOAD_CONST 2 ('x')\r\n 18 STORE_SUBSCR\r\n 20 LOAD_CONST 3 (None)\r\n 22 RETURN_VALUE\r\n\r\n 2 \u003e\u003e 24 LOAD_CONST 3 (None)\r\n 26 RETURN_VALUE\r\n```\r\n\r\nThere is no `SETUP_ANNOTATIONS` opcode generated despite the `__annotations__` access later on. (Found via https://github.com/google/pytype/issues/1435 - for some reason this does not generate a runtime error, but it does cause issues for tools like pytype.)\r\n\r\n# Your environment\r\n\r\ncpython 3.10\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105177\n* gh-105313\n* gh-105314\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/martindemello","@type":"Person","name":"martindemello"},"datePublished":"2023-05-31T18:31:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/105164/cpython/issues/105164"}
| 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:e5745d06-00af-b8f8-21fe-a29f0b6a0a6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA50:3B47BE:F6238:14C396:6969C802 |
| html-safe-nonce | 6aa95bc3c46f7b93452b700dbd83922ce6120948611a1a987ab453a8bf0f72ee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTUwOjNCNDdCRTpGNjIzODoxNEMzOTY6Njk2OUM4MDIiLCJ2aXNpdG9yX2lkIjoiNDk0MzAwOTg5MDU4MjUxMzY2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 348730303378653388895288d24a0176badbcc84d516c5d02442983097e8e91a |
| hovercard-subject-tag | issue:1734773146 |
| 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/cpython/105164/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8c836337bff4518bc780caa1116dafb562dfc9ca6afc0de8a7863a2213d3b528/python/cpython/issues/105164 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8c836337bff4518bc780caa1116dafb562dfc9ca6afc0de8a7863a2213d3b528/python/cpython/issues/105164 |
| og:image:alt | Bug report Compiling the following code: match 0: case 0: x: int = 1 generates 1 0 LOAD_CONST 0 (0) 2 2 LOAD_CONST 0 (0) 4 COMPARE_OP 2 (==) 6 POP_JUMP_IF_FALSE 12 (to 24) 3 8 LOAD_CONST 1 (1) 10 S... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | martindemello |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width