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

ASR: String to List Conversion #1079

Merged
merged 4 commits into from
Sep 5, 2022
Merged

Conversation

Smit-create
Copy link
Collaborator

@Thirumalai-Shaktivel
Copy link
Collaborator

Thirumalai-Shaktivel commented Sep 5, 2022

LGTM, Thank you!
The following are to be implemented after this PR is merged:

x = list()
x = list([])
x = list("lpython")

@czgdp1807
Copy link
Collaborator

Will this work for runtime string variables?

@Smit-create
Copy link
Collaborator Author

I will add the LLVM backend as a follow-up for runtime values.

tests/cast.py Show resolved Hide resolved
x = list("L")
assert len(x) == 1 and x[0] == 'L'

f()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is okay. Really surprising though. None of the variables (s, x) are marked as constant but still they work with only the compile time logic you have added.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is because if we have a string value at compile time then we can directly make a list constant out of it. So no cast, in that case, is required.

@czgdp1807 czgdp1807 merged commit 3a70e78 into lcompilers:main Sep 5, 2022
@Smit-create Smit-create deleted the strtolist branch September 5, 2022 09:39
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.

3 participants