Inner structs are allowed to be declared as data scoped

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
Boondorl
Posts: 138
Joined: Wed Jul 11, 2018 10:57 pm

Inner structs are allowed to be declared as data scoped

Post by Boondorl »

Normally the clearscope keyword isn't allowed with member variables, but an oversight allows inner structs to be declared as such. When creating a field of that type, the field will also have data scope. This means that the UI and playsim can both fully read and write to it as they please. Example:

Code: Select all

version "4.8"

class Test : EventHandler
{
	struct T clearscope
        {
		int v;
	}
	
	T tester;
	override void UITick()
	{
		console.printf("%d", tester.v);
		tester.v = 3;
	}
	
	override void WorldTick()
	{
		console.printf("%d", tester.v);
		tester.v = 6;
	}
}
When tested in game, you'll notice that there are no read or write access errors and that the value will update based on whether the playsim or UI updated it last.

Return to “Bugs [GZDoom]”