-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[Mojo-stdlib] Remove FLAG_IS_STATIC_CONSTANT
from the String
struct
#4661
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
[Mojo-stdlib] Remove FLAG_IS_STATIC_CONSTANT
from the String
struct
#4661
Conversation
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
FLAG_IS_STATIC_CONSTANT
from the String
struct, freeing one bitFLAG_IS_STATIC_CONSTANT
from the String
struct
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.
Nice clean up, thanks @gabrieldemarmiesse! 👍
!sync |
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 fantastic, thank you @gabrieldemarmiesse . Please update the String Design doc if needed as well.
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
@lattner I changed the string proposal document to reflect this change. @JoeLoser I also addressed your comment in this PR. It's unreleated, so let me know if you want a separate PR instead for a cleaner git history. |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Let's tease that out to a separate PR that I'll sync and land immediately, please. I suspect this PR may run into a few test failures and I don't want to hold that changelog entry up with this. |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
@JoeLoser done :) |
@gabrieldemarmiesse looks like a few tests are failing as you can see in the Bazel builds (e.g. https://github.com/modular/modular/actions/runs/15196447847/job/42741618384?pr=4661). You can repro with |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
@JoeLoser I fixed the unit tests. After a long investigation, I've put in evidence that there is currently (in After finding the exact pattern which caused the error to trigger, it was quite easy to find a solution. Assigning local variables worked, but i've opt in to just do I'm not particularily eager to try to find the root of the UB or the miscompilation, so if someone else wants to do it, feel free to |
Ooof, this looks like a fun one to track down. Awesome work chasing this down and fixing the unit tests @gabrieldemarmiesse! I'll mention this internally and someone will take a look; the community is also free to take a look (@soraros may be interested). I won't be able to take a look for a little while since I'm out on PTO next week. I'll sync this in so we can land it 👍 🎉 |
!sync |
I will try to track down this UB. It's gonna be so fun. 🙃 |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
2e7d26d
to
0af95c4
Compare
I have read the CLA Document and I hereby sign the CLA 1 out of 2 committers have signed the CLA. |
I have read the CLA Document and I hereby sign the CLA |
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: gabrieldemarmiesse <gabrieldemarmiesse@gmail.com>
Signed-off-by: Chris Lattner <lattner@users.noreply.github.com>
@JoeLoser is there a path to getting this landed, Gabriel has been very patient here and it is a nice improvement 🙏 |
!sync |
Agreed! Sorry for the delay - I was on PTO and just came back today. Now that CI is passing, I've resynced this and it should land soon. |
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
Landed in a423ce1! Thank you for your contribution 🎉 |
While poking around in the
String
struct, I noticed that it was actually possible to know if we point to aStaticString
without the need to read the flagFLAG_IS_STATIC_CONSTANT
. We can use the condition "pointer is not null and capacity is 0".I also simplify the
String()
constructor in the process. Let's remove the flag and make it available for future use cases.See https://github.com/modular/modular/blob/main/mojo/proposals/string-design.md for more info on the subject:
@lattner expressed his desire to do this in this discord message