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

Method calling doesn't work inside methods #2781

Closed
tanay-man opened this issue Jul 19, 2024 · 0 comments · Fixed by #2782
Closed

Method calling doesn't work inside methods #2781

tanay-man opened this issue Jul 19, 2024 · 0 comments · Fixed by #2782

Comments

@tanay-man
Copy link
Contributor

Ex:

from lpython import f64
from math import pi

class Circle:
    def __init__(self:"Circle", radius:f64):
        self.radius :f64 = radius
    
    def circle_area(self:"Circle")->f64:
        return pi * self.radius ** 2.0
    
    def circle_print(self:"Circle"):
        area : f64 = self.circle_area()
        print("Circle: r = ",str(self.radius)," area = ",str(area))

def main():
    c : Circle = Circle(1.0)  
    c.circle_print() 
    c.radius = 1.5   
    c.circle_print()

main()

This results in a SEGFAULT as the self variable is not initialised before function call. I think atleast the class_type should be set to the parent class.
@Thirumalai-Shaktivel

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

Successfully merging a pull request may close this issue.

1 participant