-
Notifications
You must be signed in to change notification settings - Fork 171
New string Method endswith()
support
#1606
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
Conversation
CI fails because of this:
That's an error generated from the |
Hmm. Quite weird though. That is one of my test cases which I added for integration test. It says a stray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. @Smit-create Please fix the CI and then I will approve after reviewing it for the second time.
This is fine for now, eventually this should probably be an IntrinsicFunction as well. |
By Intrinsic Function you mean like how |
Ready for review @czgdp1807 and @Smit-create |
If done reviewing, can you please merge these changes? @czgdp1807 @certik |
res = std::equal(suffix.rbegin(), suffix.rend(), s_var.rbegin()); | ||
|
||
tmp = ASR::make_LogicalConstant_t(al, loc, res, | ||
ASRUtils::TYPE(ASR::make_Logical_t(al, loc, 4, nullptr, 0))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is doing a compile time optimization. I think this should rather be implemented in the optimizer, but not done by the frontend, since ASR is then being lowered, and when we convert ASR back to Python, the original code is not recovered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be refactored into IntrinsicFunction. Just add a new function. We will have thousands of such functions eventually.
@certik How can I go on with refactoring of code to Intrinsic Functions? Can you give a head start? Because what I understood from @Thirumalai-Shaktivel is that we have to sync between LPython and LFortran for that. Can you give some pointers here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have to sync first. Until then, you can implement this in LFortran itself, in libasr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where in libasr? Can you give an example of one such addition in LFortran? Maybe a previous PR or something. @certik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in src/libasr.
Just look into merged PRs and search IntrinsicFunction. See also #1616 that is porting it to LPython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine. It adds technical debt, since I think we really have to handle these things with the IntrinsicFunction approach and handle all optimizations in the optimizer and simplify the frontend. And then reuse this in LFortran as well (if desired).
I am going to merge it, as I think generally it is done well, but we need to focus on the proper design from now on, to reduce technical debt going forward.
This should be refactored into IntrinsicFunction. Just add a new function. We will have thousands of such functions eventually. |
str.endswith(suffix)
functionality which returnsTrue
if the string ends with the specified suffix, otherwise returnFalse
endswith()
functionality.Can you please review? @certik @Thirumalai-Shaktivel @Smit-create @czgdp1807