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

Member initialisation doesn't work for cast i64 #2722

Open
Thirumalai-Shaktivel opened this issue Jun 3, 2024 · 9 comments
Open

Member initialisation doesn't work for cast i64 #2722

Thirumalai-Shaktivel opened this issue Jun 3, 2024 · 9 comments
Labels
asr ASR related changes

Comments

@Thirumalai-Shaktivel
Copy link
Collaborator

MRE:

from lpython import i32

class test:
    x: i32 = i64(4)

t: test = test()
print(t.x)
@Thirumalai-Shaktivel Thirumalai-Shaktivel added the asr ASR related changes label Jun 3, 2024
@Thirumalai-Shaktivel
Copy link
Collaborator Author

Assigned: @tanay-man

@Thirumalai-Shaktivel
Copy link
Collaborator Author

Thirumalai-Shaktivel commented Jun 3, 2024

I think the Constant number might be handled in the data member initialisation. With that case, for this we need to handle the Call node. Check for the runtime assignments, if allowed by CPython.

@Thirumalai-Shaktivel
Copy link
Collaborator Author

Thirumalai-Shaktivel commented Jun 12, 2024

This doesn't work for dataclass as well.

from lpython import i32, i64

@dataclass
class test:
    i: i64 = i64(4)

t: test = test()

print(t)

@certik
Copy link
Contributor

certik commented Jun 12, 2024

Note that x: i32 = i64(4) must be a compiler error, since the types do not match.

@certik
Copy link
Contributor

certik commented Jun 12, 2024

I am not sure if we need to support this use case at all, since this is a class variable. I would say in terms of priorities, this is below regular instance variables and inheritance / virtual functions.

@tanay-man
Copy link
Contributor

Note that x: i32 = i64(4) must be a compiler error, since the types do not match.

That is a typo, it should be x : i64 = i64(4).

@tanay-man
Copy link
Contributor

I am not sure if we need to support this use case at all, since this is a class variable. I would say in terms of priorities, this is below regular instance variables and inheritance / virtual functions.

This is fixed in the latest commit. 4 tests were failing due to this, that is why I was trying to fix this.

@Thirumalai-Shaktivel
Copy link
Collaborator Author

@tanay-man we will handle this later. We will complete the initial implementation and move on to other implementations

@tanay-man
Copy link
Contributor

tanay-man commented Jul 17, 2024

@Thirumalai-Shaktivel can you close this as it is fixed?

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

No branches or pull requests

3 participants