[Fixed] ZScript: Assertion failure in code generator

Bugs that have been investigated and resolved somehow.

Moderator: Developers

ZScript: Assertion failure in code generator

Postby Player701 » Wed Oct 31, 2018 1:51 am

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

Code: Select allExpand view
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 6 times
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: ZScript: Assertion failure in code generator

Postby Graf Zahl » Wed Oct 31, 2018 2:17 am

That code should be legal. An assignment should have a well defined result.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Assertion failure in code generator

Postby _mental_ » Thu Nov 01, 2018 9:16 am

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

Re: ZScript: Assertion failure in code generator

Postby Graf Zahl » Thu Nov 01, 2018 9: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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript: Assertion failure in code generator

Postby _mental_ » Thu Nov 01, 2018 9:25 am

Yes, I meant code like this
Code: Select allExpand view
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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: ZScript: Assertion failure in code generator

Postby Player701 » Thu Nov 01, 2018 10: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 :)
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest