ZScript: self used outside of member function (const array)

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

ZScript: self used outside of member function (const array)

Post by Player701 »

Discovered while looking at the code in this post, but here is a simpler example. The following ZScript will make GZDoom produce an error message:

Code: Select all

class TestClass
{
    static const int ConstArray[] = { 1 };
    
    static int Test()    
    {
        return ConstArray[0];
    }
}

Code: Select all

Script error, "zscript.txt:ZSCRIPT" line 7:
self used outside of a member function
This can be fixed by changing "return ConstArray[0]" to "return TestClass.ConstArray[0]". However, since ConstArray is declared as static, and the function is contained within the same class where ConstArray is declared, this shouldn't be needed.

Tested in GZDoom 3.6.0, g3.7pre-182-gb1d35eb0b
Attachments
zscript.txt
(145 Bytes) Downloaded 87 times

Return to “Bugs [GZDoom]”