ZScript: Unable to dereference left side of...

These bugs do plan to be resolved, when they can be.

Moderator: GZDoom Developers

User avatar
Player701
 
 
Posts: 1471
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

ZScript: Unable to dereference left side of...

Post by Player701 »

Trying to compile the following ZScript will make GZDoom produce an error message:

Code: Select all

version "3.4"

class Test
{
    vector2 GetVector()
    {
        return (0, 0);
    }
    
    double GetX()
    {
        return GetVector().X;
    }
}

Code: Select all

Script error, "zscript.txt:ZSCRIPT" line 12:
Unable to dereference left side of X
However, this will work:

Code: Select all

version "3.4"

class Test
{
    vector2 GetVector()
    {
        return (0, 0);
    }
    
    double GetX()
    {
        let v = GetVector();
        return v.X;
    }
}
If I need only the X (or Y) component of the vector and there is no need to use it elsewhere, then I don't need a variable to store it. Therefore, I think this is a bug and the first example should compile.
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: 48374
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript: Unable to dereference left side of...

Post by Graf Zahl »

This is a known limitation of how function calls work. Don't expect any quick results here.
User avatar
Player701
 
 
Posts: 1471
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: ZScript: Unable to dereference left side of...

Post by Player701 »

Graf Zahl wrote:This is a known limitation of how function calls work. Don't expect any quick results here.
I see. I can live with this, of course, I just wanted to report seemingly inconsistent behavior that I noticed.

Another thing I noticed is the apparent inability to declare multiple variables and assign them to a multi-value returning function in one line of code, but in this case I can't even guess what the syntax for that should be. I suppose this was never planned in the first place. I haven't seen a lot of use for this kind of functions in my code anyway...

Return to “On Hold Bugs”