Title: Inplace class definitions causes infinite looping · Issue #2826 · lcompilers/lpython · GitHub
Open Graph Title: Inplace class definitions causes infinite looping · Issue #2826 · lcompilers/lpython
X Title: Inplace class definitions causes infinite looping · Issue #2826 · lcompilers/lpython
Description: class Foo: def __init__(self: "Foo", bar: i32): self.bar: i32 = bar def __repr__(self: "Foo") -> str: return str(self.bar) def main(): a: Foo = Foo(10) print(a) main() Works fine but if we make a Foo instance inplace in print def main():...
Open Graph Description: class Foo: def __init__(self: "Foo", bar: i32): self.bar: i32 = bar def __repr__(self: "Foo") -> str: return str(self.bar) def main(): a: Foo = Foo(10) print(a) main() Works fine but if we make a F...
X Description: class Foo: def __init__(self: "Foo", bar: i32): self.bar: i32 = bar def __repr__(self: "Foo") -> str: return str(self.bar) def main(): a: Foo = Foo(10) print(a) main() Works ...
Opengraph URL: https://github.com/lcompilers/lpython/issues/2826
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inplace class definitions causes infinite looping","articleBody":"```py\nclass Foo:\n def __init__(self: \"Foo\", bar: i32):\n self.bar: i32 = bar\n\n def __repr__(self: \"Foo\") -\u003e str:\n return str(self.bar)\n\n\ndef main():\n a: Foo = Foo(10)\n print(a)\n\n\nmain()\n```\n\nWorks fine but if we make a Foo instance inplace in print\n\n```py\ndef main():\n print(Foo(10))\n```\n\nthis causes an infinite loop.\n\nThis also happens in case of functions taking in a Foo param\n\n```py\ndef foobar(a: Foo):\n print(a)\n```\n\nI imagine we need to add an error for as of now unsupported feature\n\nPS: I had encountered a similar problem in my [PR](https://github.com/lcompilers/lpython/pull/2822) I simply threw an error for that case\n\n","author":{"url":"https://github.com/swamishiju","@type":"Person","name":"swamishiju"},"datePublished":"2025-02-24T11:23:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2826/lpython/issues/2826"}
| 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:a81b9229-bb61-2df4-0d35-5bb844bdee7d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A248:C551D:1CF10F7:2846332:69778CC8 |
| html-safe-nonce | 4c33d01432051556aca9a7363339bd21007e7a44812cbc6ae7090343abc06806 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjQ4OkM1NTFEOjFDRjEwRjc6Mjg0NjMzMjo2OTc3OENDOCIsInZpc2l0b3JfaWQiOiIzMDcxODA2MDAxMDgzMDI2NjMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ea39f1bbf60dccf8cb6c2963f12a5e7b528a23ec6f6fb4d8235ff2ab2e100802 |
| hovercard-subject-tag | issue:2874640918 |
| 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/lcompilers/lpython/2826/issue_layout |
| twitter:image | https://opengraph.githubassets.com/53e9c33a6fae2cd8ab7e7a18678fba658de798abaa2e476ee333c1ac3d7ef954/lcompilers/lpython/issues/2826 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/53e9c33a6fae2cd8ab7e7a18678fba658de798abaa2e476ee333c1ac3d7ef954/lcompilers/lpython/issues/2826 |
| og:image:alt | class Foo: def __init__(self: "Foo", bar: i32): self.bar: i32 = bar def __repr__(self: "Foo") -> str: return str(self.bar) def main(): a: Foo = Foo(10) print(a) main() Works fine but if we make a F... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | swamishiju |
| hostname | github.com |
| expected-hostname | github.com |
| None | fd37f8e74ecc49b700617ea694fa6d7b395b6c9a4b79c59b3014da220462ac69 |
| turbo-cache-control | no-preview |
| go-import | github.com/lcompilers/lpython git https://github.com/lcompilers/lpython.git |
| octolytics-dimension-user_id | 96538276 |
| octolytics-dimension-user_login | lcompilers |
| octolytics-dimension-repository_id | 442864346 |
| octolytics-dimension-repository_nwo | lcompilers/lpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 442864346 |
| octolytics-dimension-repository_network_root_nwo | lcompilers/lpython |
| 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 | acb9f387e67b45e2eeb6a57ef561ec67eb21d805 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width