Assertion failure with unary minus on bool

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Assertion failure with unary minus on bool

Re: Assertion failure with unary minus on bool

by Graf Zahl » Thu Jan 10, 2019 5:21 am

That's correct.

Re: Assertion failure with unary minus on bool

by _mental_ » Thu Jan 10, 2019 5:08 am

Made this PR to be sure I got it right. As expected with this change generated code remains the same.

Re: Assertion failure with unary minus on bool

by Graf Zahl » Wed Jan 09, 2019 8:47 am

The problem is that the Resolve function does not properly promote the type if the operand is bool.

Assertion failure with unary minus on bool

by _mental_ » Wed Jan 09, 2019 8:06 am

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

Code: Select all

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.

Top