Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inplace class definitions causes infinite looping #2826

Open
swamishiju opened this issue Feb 24, 2025 · 0 comments
Open

Inplace class definitions causes infinite looping #2826

swamishiju opened this issue Feb 24, 2025 · 0 comments

Comments

@swamishiju
Copy link

swamishiju commented Feb 24, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant