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/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:89b47700-8508-51a0-46ce-4595367298e0
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA6D4:2C62EA:30C2474:439A36F:6977C1F8
html-safe-nonce4241ac9538badaa204eb6985d91cb535629cb0c3da4705453173e230f04f8116
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkQ0OjJDNjJFQTozMEMyNDc0OjQzOUEzNkY6Njk3N0MxRjgiLCJ2aXNpdG9yX2lkIjoiMjk1ODAzODA1OTc4MzI3NTAwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac3a23c370a16536b6e374bd6b38a22c70f16be4e48a7a149362441515efeb59f5
hovercard-subject-tagpull_request:3080801794
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/lcompilers/lpython/pull/2873/files
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
Nonedd7783bd9901db88bac6bc215af7f020bc205a04ebc67e6c7def882ef2859ecd
turbo-cache-controlno-preview
diff-viewunified
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
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5d30081a77a5d66860584073cb38fd98fd7f9388
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#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%2Ffiles
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%2Ffiles
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%2Ffiles&source=header-repo&source_repo=lcompilers%2Flpython
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
Reloadhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
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/files
Fix: Raise SemanticError for unsupported inline class instantiation #2826 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#top
Show all changes 2 commits https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
fd3fbcc Fix: Raise SemanticError for unsupported inline class instantiation #… amritamishra01 Dec 8, 2025 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/commits/fd3fbcc3bd7d73925e4e573fd64d73ca41603d84
aba1f60 Merge branch 'main' into fix/inline-loop-bug amritamishra01 Dec 11, 2025 https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/commits/aba1f602d2d9d39f11acc5313d45b52a2f2e9376
Clear filters https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files
python_ast_to_asr.cpp https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-147457a9117ab6d023c02f9a359d6060c248c4216cfcb47b1fafd17d885063fe
test_inline_class_error.py https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-996495fa3e507790b6154c5ecbcdf347a03b5a2d61a138adfa8aabaf049b4510
pass_inline_class_safe.py https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-64e1e4da0bd5a40051ae7810760e5d1a882a3e59e0fa06b6088ec1f76bb5fc31
src/lpython/semantics/python_ast_to_asr.cpphttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-147457a9117ab6d023c02f9a359d6060c248c4216cfcb47b1fafd17d885063fe
View file https://patch-diff.githubusercontent.com/lcompilers/lpython/blob/aba1f602d2d9d39f11acc5313d45b52a2f2e9376/src/lpython/semantics/python_ast_to_asr.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-147457a9117ab6d023c02f9a359d6060c248c4216cfcb47b1fafd17d885063fe
https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-147457a9117ab6d023c02f9a359d6060c248c4216cfcb47b1fafd17d885063fe
tests/errors/test_inline_class_error.pyhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-996495fa3e507790b6154c5ecbcdf347a03b5a2d61a138adfa8aabaf049b4510
View file https://patch-diff.githubusercontent.com/lcompilers/lpython/blob/aba1f602d2d9d39f11acc5313d45b52a2f2e9376/tests/errors/test_inline_class_error.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/{{ revealButtonHref }}
tests/reference/pass_inline_class_safe.pyhttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/files#diff-64e1e4da0bd5a40051ae7810760e5d1a882a3e59e0fa06b6088ec1f76bb5fc31
View file https://patch-diff.githubusercontent.com/lcompilers/lpython/blob/aba1f602d2d9d39f11acc5313d45b52a2f2e9376/tests/reference/pass_inline_class_safe.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/{{ revealButtonHref }}
Please reload this pagehttps://patch-diff.githubusercontent.com/lcompilers/lpython/pull/2873/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.