ZScript: Assertion failure in code generator

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: ZScript: Assertion failure in code generator

Re: ZScript: Assertion failure in code generator

by Player701 » Thu Nov 01, 2018 9:37 am

I never ignore warnings, but I only discovered this error because I decided to try out my scripts on a debug build for an unrelated reason (the event handlers-related pull request, actually). I probably would've found the typo later anyway, though. It will now be a little easier to debug scripts with these extra warnings :)

Re: ZScript: Assertion failure in code generator

by _mental_ » Thu Nov 01, 2018 8:25 am

Yes, I meant code like this

Code: Select all

if (x = 0) console.printf("never");
if (y = 1) console.printf("always");
The idea is to notify modders about potential typos, if warnings are not ignored by them of course.

Re: ZScript: Assertion failure in code generator

by Graf Zahl » Thu Nov 01, 2018 8:18 am

I think it only can get there if the expression has a constant value but isn't a constant itself. Real constants get optimized out in the resolving pass already.

Re: ZScript: Assertion failure in code generator

by _mental_ » Thu Nov 01, 2018 8:16 am

Generated code is correct, so I just made assertion less strict and added a warning about constant conditional expression in 8597c9e.

Re: ZScript: Assertion failure in code generator

by Graf Zahl » Wed Oct 31, 2018 1:17 am

That code should be legal. An assignment should have a well defined result.

ZScript: Assertion failure in code generator

by Player701 » Wed Oct 31, 2018 12:51 am

The following ZScript triggers an assertion failure in debug builds (at least g3.7pre-130-g94688a370):

Code: Select all

class Test
{
    void DoSomething()
    {
        int x = 0;
        if (x = 0) // typo, should be "=="
        {
            // ...
        }
    }
}


In release builds, execution seems to proceed normally, but who knows what could happen then. The error does not appear if "=" is replaced with "==" (as it should be).
Attachments
zscript.txt
(162 Bytes) Downloaded 58 times

Top