remove const qualifier if required#102
Conversation
|
@VisenDev what do you think of these changes? |
|
I generally oppose using const cast unless completely necessary. However, from what I can tell it does seem to be legal behavior to mutate the result of If mutating the result of a pub fn toString(lua: *Lua, index: i32) ![:0]const u8 {Rather than const casting its result. |
|
What I read on this page https://www.lua.org/manual/5.4/manual.html#lua_tolstring (look for section 4.1.3), it is safe to mutate the result of I think I'd rather allow the caller to use |
|
@axdank do you have any thoughts? Based on the lua reference manual 4.1.3, this could be a possible footgun depending on how the returned string would be used. The safest way would be to duplicate a const string if the string needs to be stored longer than Lua would keep that pointer valid. I can imagine that someone could use Maybe this is a case for |
|
@natecraddock How about these changes? I removed the use of @castConst, so if any structure needs a mutable string field, a copy of it is created. |
|
Thank you for working on this! |
fix: