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

Implement str.replace() and str.index() #2447

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AkshayWarrier
Copy link
Contributor

Relates to #2356

I also noticed that these methods don't work with constant strings

semantic error: 'str' object has no attribute 'split'
 --> test.py:2:7
  |
2 | print("1 2 3".split())
  |       ^^^^^^^^^^^^^^^ 

and I'm guessing it's because they are not being handled in handle_constant_string_attributes.

  1. Why can't both constant strings and variable strings be handled by the _lpython_str_... functions? Because it looks like the methods for constant strings are directly being implemented in C++.
  2. Shall I also add separate implementations for these in handle_constant_string_attributes?

@Thirumalai-Shaktivel
Copy link
Collaborator

Yes, I think we handle compile-time string in python_ast_to_asr.cpp and run time string using _lpython_....
What needs to be done to complete this and merge?

Please mark this PR ready for review once it is ready.

@Thirumalai-Shaktivel Thirumalai-Shaktivel marked this pull request as draft March 5, 2024 12:21
@Kishan-Ved
Copy link
Contributor

I have implemented str.replace() completely (with support for all three parameters) here: #2587

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