ZScript: Unable to dereference left side of...

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!

ZScript: Unable to dereference left side of...

Postby Player701 » Fri Oct 19, 2018 2:09 pm

Trying to compile the following ZScript will make GZDoom produce an error message:
Code: Select allExpand view
version "3.4"

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

Code: Select allExpand view
Script error, "zscript.txt:ZSCRIPT" line 12:
Unable to dereference left side of X

However, this will work:
Code: Select allExpand view
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
Player701
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

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

Postby Graf Zahl » Fri Oct 19, 2018 2:24 pm

This is a known limitation of how function calls work. Don't expect any quick results here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Player701 » Fri Oct 19, 2018 2:57 pm

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...
User avatar
Player701
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests