Skip to content

Default constructors #2750

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

Merged
merged 11 commits into from
Jul 3, 2024
Merged

Default constructors #2750

merged 11 commits into from
Jul 3, 2024

Conversation

tanay-man
Copy link
Contributor

@tanay-man tanay-man commented Jun 27, 2024

I have implemented the simplest case of default constructors. I have also added the field member_functions to the ASR node Struct. @Thirumalai-Shaktivel @certik

@tanay-man tanay-man changed the title Default constructors are implemented Default constructors Jun 27, 2024
Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I have left some comments.

Some improvements has to be done in the visit_Constructor

Comment on lines +4 to +7
class coord:
def __init__(self: "coord"):
self.x: i32 = 3
self.y: i32 = 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, this is represented as:

class coord:
	self: "coord"
	x: i32 = 3
	y: i32 = 4

And @tanay-man wants this PR to be merged and work on the arguments initialisation in the next PR.

Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Thirumalai-Shaktivel
Copy link
Collaborator

Next implementation is:

class test:
	def __init__(self: "test", x: i32)
		self.x = x

t: test
t.__init__(t, 2)

@Thirumalai-Shaktivel
Copy link
Collaborator

@certik, I'm merging this. If you feel something is not correct, do let us know. We will correct that in the subsequent PR's.

Thank you @tanay-man for working on this.

@Thirumalai-Shaktivel Thirumalai-Shaktivel merged commit 98227da into lcompilers:main Jul 3, 2024
14 checks passed
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 this pull request may close these issues.

2 participants