Page 1 of 1

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

Posted: Tue Nov 06, 2018 6:36 am
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