René's URL Explorer Experiment


Title: Fix: Raise SemanticError for unsupported inline class instantiation #2826 by amritamishra01 · Pull Request #2873 · lcompilers/lpython · GitHub

Open Graph Title: Fix: Raise SemanticError for unsupported inline class instantiation #2826 by amritamishra01 · Pull Request #2873 · lcompilers/lpython

X Title: Fix: Raise SemanticError for unsupported inline class instantiation #2826 by amritamishra01 · Pull Request #2873 · lcompilers/lpython

Description: Summary Hi @swamishiju Fixes #2826 where the compiler hangs (infinite loop) when encountering inline class instantiation, such as print(Foo(10)). The Issue Currently, the compiler attempts to lower temporary class objects created inline but fails to handle the lifecycle correctly in python_ast_to_asr.cpp, resulting in infinite recursion/hanging during the lowering phase. The Fix I implemented a check in the semantic analysis phase (visit_Call) to detect this unsupported pattern before it reaches the lowering stage. File: src/lpython/semantics/python_ast_to_asr.cpp Logic: The visitor now checks if a function call argument is a direct Call to a Struct (Class) symbol. Action: If detected, it raises a clear SemanticError advising the user to assign the object to a variable first. Verification I added two new test cases to ensure the fix works and is safe: Error Case: tests/errors/test_inline_class_error.py Contains print(Foo(10)) and my_func(Foo(20)). Verified that it now raises a SemanticError immediately instead of hanging. Regression Test: tests/reference/pass_inline_class_safe.py Contains a = Foo(10); print(a). Verified that valid usage (assigning to a variable first) still compiles and produces correct ASR. Future Work This is a safeguard fix. Full support for inline class instantiation will require implementing proper lowering logic for temporary class objects, likely by separating symbol registration from body lowering to handle recursive resolution.

Open Graph Description: Summary Hi @swamishiju Fixes #2826 where the compiler hangs (infinite loop) when encountering inline class instantiation, such as print(Foo(10)). The Issue Currently, the compiler attempts to lowe...

X Description: Summary Hi @swamishiju Fixes #2826 where the compiler hangs (infinite loop) when encountering inline class instantiation, such as print(Foo(10)). The Issue Currently, the compiler attempts to lowe...

Opengraph URL: https://github.com/lcompilers/lpython/pull/2873

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:47515350-0dab-7102-2a28-b23648d82ee9
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idB7B4:1B8E26:C33C8B5:FD338A1:6976BF02
html-safe-nonce7a4059835af2d4f8806acbb0f772156f784ba0cbda08f84668cec8f8a1c9cda0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCN0I0OjFCOEUyNjpDMzNDOEI1OkZEMzM4QTE6Njk3NkJGMDIiLCJ2aXNpdG9yX2lkIjoiNzIwODg5MjMxNzkxNjY0MzA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac798f663b3911fa949dfd0899f88b60a8a41c0d554e27464781d36e428a66b5a3
hovercard-subject-tagpull_request:3080801794
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/lcompilers/lpython/pull/2873/checks
twitter:imagehttps://avatars.githubusercontent.com/u/171616930?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/171616930?s=400&v=4
og:image:altSummary Hi @swamishiju Fixes #2826 where the compiler hangs (infinite loop) when encountering inline class instantiation, such as print(Foo(10)). The Issue Currently, the compiler attempts to lowe...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None032152924a283b83384255d9489e7b93b54ba01da8d380b05ecd3953b3212411
turbo-cache-controlno-cache
go-importgithub.com/lcompilers/lpython git https://github.com/lcompilers/lpython.git
octolytics-dimension-user_id96538276
octolytics-dimension-user_loginlcompilers
octolytics-dimension-repository_id442864346
octolytics-dimension-repository_nwolcompilers/lpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id442864346
octolytics-dimension-repository_network_root_nwolcompilers/lpython
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5b577f6be6482e336e3c30e8daefa30144947b17
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Flcompilers%2Flpython%2Fpull%2F2873%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Flcompilers%2Flpython%2Fpull%2F2873%2Fchecks
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=lcompilers%2Flpython
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
lcompilers https://patch-diff.githubusercontent.com/lcompilers
lpythonhttps://patch-diff.githubusercontent.com/lcompilers/lpython
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Flcompilers%2Flpython
Fork 173 https://patch-diff.githubusercontent.com/login?return_to=%2Flcompilers%2Flpython
Star 1.6k https://patch-diff.githubusercontent.com/login?return_to=%2Flcompilers%2Flpython
Code https://patch-diff.githubusercontent.com/lcompilers/lpython
Issues 503 https://patch-diff.githubusercontent.com/lcompilers/lpython/issues
Pull requests 85 https://patch-diff.githubusercontent.com/lcompilers/lpython/pulls
Actions https://patch-diff.githubusercontent.com/lcompilers/lpython/actions
Projects 0 https://patch-diff.githubusercontent.com/lcompilers/lpython/projects
Wiki https://patch-diff.githubusercontent.com/lcompilers/lpython/wiki
Security 0 https://patch-diff.githubusercontent.com/lcompilers/lpython/security
Insights https://patch-diff.githubusercontent.com/lcompilers/lpython/pulse
Code https://patch-diff.githubusercontent.com/lcompilers/lpython
Issues https://patch-diff.githubusercontent.com/lcompilers/lpython/issues
Pull requests https://patch-diff.githubusercontent.com/lcompilers/lpython/pulls
Actions https://patch-diff.githubusercontent.com/lcompilers/lpython/actions
Projects https://patch-diff.githubusercontent.com/lcompilers/lpython/projects
Wiki https://patch-diff.githubusercontent.com/lcompilers/lpython/wiki
Security https://patch-diff.githubusercontent.com/lcompilers/lpython/security
Insights https://patch-diff.githubusercontent.com/lcompilers/lpython/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Flcompilers%2Flpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Flcompilers%2Flpython%2Fissues%2Fnew%2Fchoose
amritamishra01https://patch-diff.githubusercontent.com/amritamishra01
lcompilers:mainhttps://patch-diff.githubusercontent.com/lcompilers/lpython/tree/main
amritamishra01:fix/inline-loop-bughttps://patch-diff.githubusercontent.com/amritamishra01/lpython/tree/fix/inline-loop-bug
Conversation 3 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873
Commits 2 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/commits
Checks 18 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
Files changed https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
Sign in for the full log viewhttps://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Flcompilers%2Flpython%2Fpull%2F2873%2Fchecks
Fix: Raise SemanticError for unsupported inline class instantiation #2826 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks#top
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/checks
LPython CI on: pull_request https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309
LPython CI (3.10, ubuntu-latest) https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976536?pr=2873
LPython CI (3.10, macos-latest) https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976539?pr=2873
LPython CI (3.10, windows-2025) https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976561?pr=2873
Build LPython to WASM https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976488?pr=2873
Test PIP Installable Packages https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976511?pr=2873
Check Debug build https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976506?pr=2873
Check Release build https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976478?pr=2873
Test CPython Interop (@pythoncall) https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976475?pr=2873
Run SymPy tests https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976529?pr=2873
Run Integration tests with Python 3.9 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976542?pr=2873
Run Integration tests with Python 3.10 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976533?pr=2873
Run Integration tests with Python 3.11 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976524?pr=2873
Run Integration tests with Python 3.12 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976531?pr=2873
Test LLVM 10 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976553?pr=2873
Test LLVM 15 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976557?pr=2873
Test LLVM 16 https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976552?pr=2873
Build Jupyter Kernel https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976547?pr=2873
Upload Tarball https://patch-diff.githubusercontent.com/lcompilers/lpython/actions/runs/20131542309/job/57773976526?pr=2873
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.