Is it possible to convert an Int to a String at comp time?
Hey all, I'm trying to make some comp time friendly structs for my project. I'm struggling with converting an int to a string for some string concatenations.
str()
does not work at comp time.
Minimal example to reproduce the error.
10 Replies
well i guess my question would be, if it’s at comp time then you know the value, why not just use a string?
I think this should work. Could you file an issue on GH
Here's an example of where it's blocking
I need to perform some operations with it as an Int, then return a String.
got it, understood
I'll file an issue and see what happens, thanks! Wasn't sure if I was just doing something that doesn't make sense at comp time
i agree that this is an issue but i also think there could be a workaround
unsafe but maybe try creating a string with the necessary space then putting the correct values into the buffer for it
not sure if that would work at comp time tho
Worth a try! I'm not too pressed to make it work immediately, but whenever it's possible it'll be nice time saver haha.
Whats the issue number :)?
GitHub
[BUG] Mojo crashes when attempting run
str()
during compilation. ...Bug description Running str() within in an alias causes the compiler to crash. I think we should be able to convert Stringables to String during compilation unless I'm missing something. Thanks...
Congrats @toasty, you just advanced to level 5!