mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
Fix weird ternary operator in torquescript regression
With a test!
This commit is contained in:
parent
35de012ee7
commit
59125c85eb
2 changed files with 22 additions and 1 deletions
|
|
@ -399,7 +399,12 @@ U32 ConditionalExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
|
|||
|
||||
TypeReq ConditionalExprNode::getPreferredType()
|
||||
{
|
||||
return trueExpr->getPreferredType();
|
||||
// We can't make it calculate a type based on subsequent expressions as the expression
|
||||
// could be a string, or just numbers. To play it safe, stringify anything that deals with
|
||||
// a conditional, and let the interpreter cast as needed to other types safely.
|
||||
//
|
||||
// See: Regression Test 7 in ScriptTest. It has a string result in the else portion of the ?: ternary.
|
||||
return TypeReqString;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue