ZScript: Assertion failure in code generator

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

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.
User avatar
Player701
 
 
Posts: 1651
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

ZScript: Assertion failure in code generator

Post by Player701 »

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).
You do not have the required permissions to view the files attached to this post.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49141
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript: Assertion failure in code generator

Post by Graf Zahl »

That code should be legal. An assignment should have a well defined result.
_mental_
 
 
Posts: 3814
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript: Assertion failure in code generator

Post by _mental_ »

Generated code is correct, so I just made assertion less strict and added a warning about constant conditional expression in 8597c9e.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49141
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript: Assertion failure in code generator

Post by Graf Zahl »

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.
_mental_
 
 
Posts: 3814
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript: Assertion failure in code generator

Post by _mental_ »

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.
User avatar
Player701
 
 
Posts: 1651
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: ZScript: Assertion failure in code generator

Post by Player701 »

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 :)

Return to “Closed Bugs [GZDoom]”