You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned in my previous issue, when you try to match current_player or a similar variable to a piece of text in an if statement (e.g. if current_player == "DutifulLake") then the program will crash if you try to compile the code like that.
The text was updated successfully, but these errors were encountered:
for each player do
if current_player == "DavidJCobb" then
end
end
String literals can't be compared in this manner, and you can't access or test the name of the player that a player variable refers to; however, this should only emit a compiler error and not crash.
The crash occurs in compiler.cpp line 1618, function Compiler::_parseCondition, when attempting to assign an owning statement to the righthand side of the expression. There is no righthand side -- rhs is nullptr.
At line 1589 in the same function, we detect the case of the RHS being a string literal and emit an error; however, the error is non-fatal, and we don't return, so execution continues onward and we attempt to process the full expression as if it were valid. What we need to do instead is check if both lhs and rhs exist, immediately before we create a new Script::Comparison, and return early if either is nullptr. Aborting execution at the moment we detect a string is not ideal, as we want to make sure we can parse the whole expression if the string is on the lefthand side (i.e. we should handle each side consistently: log an error, parse the rest of the statement, and then abort on creating an in-memory statement object if the statement would not be valid).
As mentioned in my previous issue, when you try to match current_player or a similar variable to a piece of text in an if statement (e.g. if current_player == "DutifulLake") then the program will crash if you try to compile the code like that.
The text was updated successfully, but these errors were encountered: