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

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!

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: ZScript: self used outside of member function (const array)

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

by Player701 » Tue Nov 06, 2018 6:36 am

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 89 times

Top