René's URL Explorer Experiment


Title: Fix "tried to pop from empty stack" with BlockExpr and const by im-0 · Pull Request #7916 · RustPython/RustPython · GitHub

Open Graph Title: Fix "tried to pop from empty stack" with BlockExpr and const by im-0 · Pull Request #7916 · RustPython/RustPython

X Title: Fix "tried to pop from empty stack" with BlockExpr and const by im-0 · Pull Request #7916 · RustPython/RustPython

Description: Constant expressions without side effects are optimized away unless in an interactive mode. This causes panic when last statement in a block is a constant and Mode::BlockExpr is used as this constant value must be returned to caller. ---- vm::python_run::tests::test_block_expr_return_const stdout ---- [crates/vm/src/frame.rs:9653:9] self = ExecutingFrame { code: code: at ??? file "", line 1>, stack_len: 0, } thread 'vm::python_run::tests::test_block_expr_return_const' (2640752) panicked at crates/vm/src/frame.rs:9410:18: tried to pop from empty stack stack backtrace: 0: __rustc::rust_begin_unwind at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/panicking.rs:689:5 1: core::panicking::panic_fmt at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/panicking.rs:80:14 2: rustpython_vm::frame::ExecutingFrame::fatal at ./src/frame.rs:9654:9 3: rustpython_vm::frame::ExecutingFrame::pop_stackref_opt at ./src/frame.rs:9410:18 4: rustpython_vm::frame::ExecutingFrame::pop_stackref at ./src/frame.rs:9420:18 5: rustpython_vm::frame::ExecutingFrame::pop_value at ./src/frame.rs:9435:14 6: rustpython_vm::frame::ExecutingFrame::execute_instruction at ./src/frame.rs:3391:34 7: rustpython_vm::frame::ExecutingFrame::run at ./src/frame.rs:1623:31 8: rustpython_vm::frame::>::run::{{closure}} at ./src/frame.rs:1098:44 9: rustpython_vm::frame::>::with_exec at ./src/frame.rs:1093:9 10: rustpython_vm::frame::>::run at ./src/frame.rs:1098:14 11: rustpython_vm::vm::VirtualMachine::run_frame::{{closure}} at ./src/vm/mod.rs:1201:44 12: rustpython_vm::vm::VirtualMachine::with_frame_impl::{{closure}}::{{closure}} at ./src/vm/mod.rs:1610:60 13: rustpython_vm::vm::VirtualMachine::dispatch_traced_frame at ./src/vm/mod.rs:1689:22 14: rustpython_vm::vm::VirtualMachine::with_frame_impl::{{closure}} at ./src/vm/mod.rs:1610:22 15: rustpython_vm::vm::VirtualMachine::with_recursion at ./src/vm/mod.rs:1547:9 16: rustpython_vm::vm::VirtualMachine::with_frame_impl at ./src/vm/mod.rs:1572:14 17: rustpython_vm::vm::VirtualMachine::with_frame at ./src/vm/mod.rs:1555:14 18: rustpython_vm::vm::VirtualMachine::run_frame at ./src/vm/mod.rs:1201:20 19: rustpython_vm::vm::VirtualMachine::run_code_obj at ./src/vm/mod.rs:1120:14 20: rustpython_vm::vm::python_run::::run_block_expr at ./src/vm/python_run.rs:51:14 21: rustpython_vm::vm::python_run::tests::test_block_expr_return_const::{{closure}} at ./src/vm/python_run.rs:190:47 22: rustpython_vm::vm::interpreter::Interpreter::enter::{{closure}} at ./src/vm/interpreter.rs:366:39 23: rustpython_vm::vm::thread::set_current_vm::{{closure}} at ./src/vm/thread.rs:107:9 24: std::thread::local::LocalKey::try_with at /home/im/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:513:12 25: std::thread::local::LocalKey::with at /home/im/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:477:20 26: rustpython_vm::vm::thread::set_current_vm at ./src/vm/thread.rs:102:14 27: rustpython_vm::vm::thread::enter_vm at ./src/vm/thread.rs:132:5 28: rustpython_vm::vm::interpreter::Interpreter::enter at ./src/vm/interpreter.rs:366:9 29: rustpython_vm::vm::python_run::tests::test_block_expr_return_const at ./src/vm/python_run.rs:188:23 30: rustpython_vm::vm::python_run::tests::test_block_expr_return_const::{{closure}} at ./src/vm/python_run.rs:187:38 31: core::ops::function::FnOnce::call_once at /home/im/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5 32: core::result::Result<(), alloc::string::String> as core::ops::function::FnOnce<()>>::call_once at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/ops/function.rs:250:5 Simple test case included. Summary by CodeRabbit Refactor Improved compilation efficiency for constant expressions in statement blocks.

Open Graph Description: Constant expressions without side effects are optimized away unless in an interactive mode. This causes panic when last statement in a block is a constant and Mode::BlockExpr is used as this consta...

X Description: Constant expressions without side effects are optimized away unless in an interactive mode. This causes panic when last statement in a block is a constant and Mode::BlockExpr is used as this consta...

Opengraph URL: https://github.com/RustPython/RustPython/pull/7916

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8eb2a2d7-2b8e-1dda-08e0-f049c2bbbbdf
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBC78:1FFA70:31EC6F:44374E:6A5FABC1
html-safe-nonce568fcb35d9a2c0091936a08c5657ffb2a22a36a14976c22fc93b0938c347ed20
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzc4OjFGRkE3MDozMUVDNkY6NDQzNzRFOjZBNUZBQkMxIiwidmlzaXRvcl9pZCI6IjQxMzA5MTg2NzU3NDM4MTUwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac250127a7ad4b05ae2a9207161b9704a6f2c9dc2d2a38bbbdc248c71bbe1e62cb
hovercard-subject-tagpull_request:3704170186
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/7916/files
twitter:imagehttps://avatars.githubusercontent.com/u/18099621?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/18099621?s=400&v=4
og:image:altConstant expressions without side effects are optimized away unless in an interactive mode. This causes panic when last statement in a block is a constant and Mode::BlockExpr is used as this consta...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None9b835c054d57dfb6ce72ba8f0eb8f16f0370860631609eb10df818738c61c68d
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4df9bc0bde4bfd7cd95e75afdd7f103984ece3a1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/7916/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7916%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7916%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/7916/files
Reloadhttps://github.com/RustPython/RustPython/pull/7916/files
Reloadhttps://github.com/RustPython/RustPython/pull/7916/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7916/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 294 https://github.com/RustPython/RustPython/issues
Pull requests 105 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
im-0:fix-block-exprhttps://github.com/im-0/RustPython/tree/fix-block-expr
Conversation 3 https://github.com/RustPython/RustPython/pull/7916
Commits 2 https://github.com/RustPython/RustPython/pull/7916/commits
Checks 25 https://github.com/RustPython/RustPython/pull/7916/checks
Files changed https://github.com/RustPython/RustPython/pull/7916/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7916/files
Fix "tried to pop from empty stack" with BlockExpr and const https://github.com/RustPython/RustPython/pull/7916/files#top
Show all changes 2 commits https://github.com/RustPython/RustPython/pull/7916/files
899fac4 Add tests for Mode::BlockExpr and VirtualMachine::run_block_expr im-0 May 18, 2026 https://github.com/RustPython/RustPython/pull/7916/commits/899fac4a9b8ac57557a47c0d4e246732198953e6
239ff88 Fix "tried to pop from empty stack" with BlockExpr and const im-0 May 17, 2026 https://github.com/RustPython/RustPython/pull/7916/commits/239ff886578a0930cc0612ab3ec35eb718cb8a49
Clear filters https://github.com/RustPython/RustPython/pull/7916/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7916/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7916/files
compile.rs https://github.com/RustPython/RustPython/pull/7916/files#diff-6a53a11ca0aa1a372032c6b54644b8cda74af0c771efa40d3668da4a042cf7ca
python_run.rs https://github.com/RustPython/RustPython/pull/7916/files#diff-ff5741056db5c8cfe1e330b23fb0ff523b4c9dcd7c4d86e3383d6abdba80713c
crates/codegen/src/compile.rshttps://github.com/RustPython/RustPython/pull/7916/files#diff-6a53a11ca0aa1a372032c6b54644b8cda74af0c771efa40d3668da4a042cf7ca
View file https://github.com/im-0/RustPython/blob/239ff886578a0930cc0612ab3ec35eb718cb8a49/crates/codegen/src/compile.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7916/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7916/files#diff-6a53a11ca0aa1a372032c6b54644b8cda74af0c771efa40d3668da4a042cf7ca
https://github.com/RustPython/RustPython/pull/7916/files#diff-6a53a11ca0aa1a372032c6b54644b8cda74af0c771efa40d3668da4a042cf7ca
crates/vm/src/vm/python_run.rshttps://github.com/RustPython/RustPython/pull/7916/files#diff-ff5741056db5c8cfe1e330b23fb0ff523b4c9dcd7c4d86e3383d6abdba80713c
View file https://github.com/im-0/RustPython/blob/239ff886578a0930cc0612ab3ec35eb718cb8a49/crates/vm/src/vm/python_run.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7916/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7916/files#diff-ff5741056db5c8cfe1e330b23fb0ff523b4c9dcd7c4d86e3383d6abdba80713c
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7916/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.