Title: Fix sub_table ordering for nested inlined comprehensions (PEP 709) by LegNeato · Pull Request #7480 · RustPython/RustPython · GitHub
Open Graph Title: Fix sub_table ordering for nested inlined comprehensions (PEP 709) by LegNeato · Pull Request #7480 · RustPython/RustPython
X Title: Fix sub_table ordering for nested inlined comprehensions (PEP 709) by LegNeato · Pull Request #7480 · RustPython/RustPython
Description: When an inlined comprehension's first iterator expression contains nested scopes (such as a lambda), those scopes' sub_tables appear at the current position in the parent's sub_table list. The previous code spliced the comprehension's own child sub_tables (e.g. inner inlined comprehensions) into that same position before compiling the iterator, which shifted the iterator's sub_tables to wrong indices. Move the splice after the first iterator is compiled so its sub_tables are consumed at their original positions. Fixes nested list comprehensions like: [[x for _, x in g] for _, g in itertools.groupby(..., lambda x: ...)] Disclosure: I used AI to develop the patch though I was heavily involved. Summary by CodeRabbit Bug Fixes Fixed nested comprehension scoping and iteration semantics for complex cases involving lambda expressions and underscore variables.
Open Graph Description: When an inlined comprehension's first iterator expression contains nested scopes (such as a lambda), those scopes' sub_tables appear at the current position in the parent's sub_table li...
X Description: When an inlined comprehension's first iterator expression contains nested scopes (such as a lambda), those scopes' sub_tables appear at the current position in the parent's ...
Opengraph URL: https://github.com/RustPython/RustPython/pull/7480
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2333a93f-6837-1c94-5527-7719373fbe9a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 80F6:11682C:489712:5E41A2:6A5BFC91 |
| html-safe-nonce | 2f21f42e3b826e1cef9d684ce771cc12fbcae74ab3d980cd32e4fa90399fa94d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEY2OjExNjgyQzo0ODk3MTI6NUU0MUEyOjZBNUJGQzkxIiwidmlzaXRvcl9pZCI6IjYyNzI2OTI0MTA2NTQ2NTM1ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b0db30ef003dfb0b4e6aa59f55bd8afcfe98d1c2aafc237d47b39f8a8303d346 |
| hovercard-subject-tag | pull_request:3429890386 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/RustPython/RustPython/pull/7480/files |
| twitter:image | https://avatars.githubusercontent.com/u/368904?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/368904?s=400&v=4 |
| og:image:alt | When an inlined comprehension's first iterator expression contains nested scopes (such as a lambda), those scopes' sub_tables appear at the current position in the parent's sub_table li... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width