[Fixed] Assertion failure with unary minus on bool

Bugs that have been investigated and resolved somehow.

Moderator: Developers

Assertion failure with unary minus on bool

Postby _mental_ » Wed Jan 09, 2019 9:06 am

Loading the following ZScript will trigger an assertion failure here: ValueType is "Int" while Operand->ValueType is "Bool".

Code: Select allExpand view
class UnaryMinusBool : Actor
{
   states
   {
   spawn:
      TNT1 A 1
      {
         bool a = false;
         int i = -a;
         
         bool b = true;
         int j = -b;
         
         console.printf("%i %i", i, j);
      }
   }
}

Generated code seems to be correct. The sample outputs expected values, 0 and -1.
I suspect the assertion's condition is too strict and doesn't take bool-to-int type propagation into account.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Assertion failure with unary minus on bool

Postby Graf Zahl » Wed Jan 09, 2019 9:47 am

The problem is that the Resolve function does not properly promote the type if the operand is bool.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Assertion failure with unary minus on bool

Postby _mental_ » Thu Jan 10, 2019 6:08 am

Made this PR to be sure I got it right. As expected with this change generated code remains the same.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Assertion failure with unary minus on bool

Postby Graf Zahl » Thu Jan 10, 2019 6:21 am

That's correct.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: Trendiction.de [Bot] and 1 guest