GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inplace class definitions causes infinite looping · Issue #2826 · lcompilers/lpython

Inplace class definitions causes infinite looping #2826

New issue
Copy link
New issue
Copy link
Open
#2873
Open
Inplace class definitions causes infinite looping#2826
#2873
Copy link

Description

@swamishiju
swamishiju
opened on Feb 24, 2025
Issue body actions
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():
    print(Foo(10))

this causes an infinite loop.

This also happens in case of functions taking in a Foo param

def foobar(a: Foo):
    print(a)

I imagine we need to add an error for as of now unsupported feature

PS: I had encountered a similar problem in my PR I simply threw an error for that case

Activity

  1. amritamishra01 commented on Nov 24, 2025

    @amritamishra01
    amritamishra01
    on Nov 24, 2025
    More actions

    Hi! I'd like to work on this issue.

    Since this bug is still open and unassigned, I’d like to investigate why inline class instantiation (e.g., print(Foo(10))) leads to an infinite loop and propose a fix — likely by detecting unsupported inline class construction and raising a clear semantic error, or by adjusting the lowering logic if appropriate.

    Please let me know if that’s okay — I can start working on it.
    Thanks!

  2. amritamishra01
    added a commit that references this issue on Dec 8, 2025

    Fix: Raise SemanticError for unsupported inline class instantiation l…

    fd3fbcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.