ZScript: Unable to dereference left side of...

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

Moderator: GZDoom Developers

Post Reply
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

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.
Attachments
zscript.txt
(168 Bytes) Downloaded 198 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
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: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

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...
Post Reply

Return to “On Hold Bugs”